Part Number Hot Search : 
14R12 SP100111 JE172 W4011BN STZ8150A 00ETT MUX24EP R8C16
Product Description
Full Text Search
 

To Download Z51F0410 Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  ps029502-0212 preliminary copyright ?2012 zilog ? , inc. all rights reserved. www.zilog.com product specification z8051 series 8-bit microcontrollers Z51F0410
ps029502-0212 p r e l i m i n a r y Z51F0410 product specification ii do not use this product in life support systems. life support policy zilog?s products are not authorized for use as critical components in life support devices or systems without th e express prior written approval of the president and general counsel of zilog corporation. as used herein life support devices or systems are devices which (a) are intended for surgical impl ant into the body, or (b) support or sustain life and whose failure to perform when properly used in accordance with instructions for use provided in the labeling can be reasonably expected to result in a signi ficant injury to the user. a criti- cal component is any component in a life support device or system whose failure to perform can be reason- ably expected to cause the failure of the life support devi ce or system or to affect its safety or effectiveness. document disclaimer ?2012 zilog, inc. all rights reserved . information in this pu blication concerning the devices, applications, or technology described is intend ed to suggest possible uses and may be superseded. zilog, inc. does not assume liability for or provide a representation of accuracy of the information, devices, or technology described in this document. zilog also does not assume liability for intellectual property infringement related in any manner to use of information, devices, or technology described herein or otherwise. the information contained w ithin this document has been verified according to the general principles of electrical and mechanical engineering. z8051 is a trademark or registered trademark of zilo g, inc. all other product or service names are the property of their respective owners. warning:
ps029502-0212 p r e l i m i n a r y revision history Z51F0410 product specification iii revision history each instance in this document?s revision history reflects a change from its previous edi- tion. for more details, refer to the corresponding page(s) or appropriate links furnished in the table below. date revision level description page feb 2012 02 removed references to sop, pdip packages. all jan 2012 01 original zilog issue. all
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 1 table of contents 1. overview ................................................................................................................... ................. 11 1.1 description ............................................................................................................... ................ 11 1.2 features .................................................................................................................. ................. 11 1.3 ordering information ...................................................................................................... .......... 12 1.3.1 part number suffix designation ........................................................................................ 1 3 1.4 development tools ......................................................................................................... ......... 13 1.4.1 compiler ................................................................................................................ ........... 13 1.4.2 ocd emulator and debugger ........................................................................................... 13 1.5 block diagram ............................................................................................................. ............. 15 1.6 pin assignment ............................................................................................................ ........... 16 1.7 package diagram ........................................................................................................... .......... 17 1.8 reconfigurable pin description ............................................................................................ .... 18 1.8.1 usart pin location switch mode .................................................................................... 18 1.8.2 i2c pin location switch mode .......................................................................................... 1 8 1.8.3 external interrupt pin location switch mode ..................................................................... 19 1.8.4 buzzer out pin location switch mode .............................................................................. 20 1.8.5 timer pin location switch mode ..................................................................................... 21 1.9 code encryption (super lock) .............................................................................................. ... 21 1.10 port structure ........................................................................................................... .............. 23 1.10.1 general purpose i/o port ................................................................................................ 23 1.10.2 external interrupt i/o port ............................................................................................ ... 24 1.11 port structure diagram (detail view) ..................................................................................... .. 25 1.11.1 p0[0] port structure ................................................................................................... ..... 25 1.11.2 p0[1] port structure ................................................................................................... ..... 26 1.11.3 p0[2] port structure ................................................................................................... ..... 27 1.11.4 p0[3] port structure ................................................................................................... ..... 29 1.11.5 p0[4] port structure ................................................................................................... ..... 31 1.11.6 p0[5] port structure ................................................................................................... ..... 33 1.11.7 p0[6]/p0[7] port structure ............................................................................................. .. 35 1.12 electrical characteristics ............................................................................................... ......... 36 1.12.1 absolute maximum ratings .............. .............................................................................. 36 1.12.2 recommended operating conditions ............................................................................. 36 1.12.3 a/d converter characteristics ......................................................................................... 36 1.12.4 voltage dropout converter characteristics ..................................................................... 37 1.12.5 power-on reset characteristics ..................................................................................... 37 1.12.6 brown out detector characteristic s ................................................................................ 38 1.12.7 internal 8mhz, 128khz rc oscillator characteristics ..................................................... 38 1.12.8 analog comparator characteristics ................................................................................ 38 1.12.9 dc characteristics ..................................................................................................... ..... 39 1.12.10 ac characteristics .................................................................................................... .... 40 1.12.11 typical characteristics ............................................................................................... ... 40 2. functional description ..................................................................................................... ............... 42 2.1 memory .................................................................................................................... ................ 42 2.1.1 program memory .......................................................................................................... .... 42 2.1.2 data memory ............................................................................................................. ....... 42
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 2 2.1.3 eeprom data memory .................................................................................................... 4 4 2.2 sfr map ................................................................................................................... ............... 45 2.2.1 sfr map summary ......................................................................................................... . 45 2.2.2 sfr map ................................................................................................................. .......... 46 2.2.3 compiler compatible sfr ................................................................................................ 49 2.3 i/o port ............................................................................................................................... ...... 51 2.3.1 i/o ports ............................................................................................................... ............. 51 2.3.2 port register ........................................................................................................... .......... 51 2.3.3 p0 port ................................................................................................................. ............. 52 3. interrupt controller ....................................................................................................... .................. 56 3.1 overview .................................................................................................................. ................ 56 3.2 external interrupt ........................................................................................................ .............. 56 3.3 block diagram ............................................................................................................. ............. 58 3.4 interrupt vector table..................................................................................................... .......... 59 3.5 interrupt sequence ........................................................................................................ ........... 59 3.6 effective timing after controlling interrupt bit .......................................................................... . 61 3.7 multi interrupt ........................................................................................................... ................ 61 3.8 interrupt enable accept timing ............................................................................................ .... 63 3.9 interrupt service routine address ............................................................................................ 63 3.10 saving/restore general-purpose registers ........................................................................... 63 3.11 interrupt timing ......................................................................................................... ............. 64 3.12 interrupt register overview .............................................................................................. ...... 64 3.12.1 interrupt enable register (ie, ie1, ie2, ie3) .................................................................... 64 3.12.2 interrupt priority register (ip, ip1) .................................................................................. 64 3.12.3 external interrupt flag register (eiflag) ...................................................................... 65 3.12.4 external interrupt edge register (e iedge) .................................................................... 65 3.12.5 external interrupt polarity register (eipola) ................................................................. 65 3.12.6 external interrupt enable register (eienab) .................................................................. 65 3.12.7 register map ................................................................................................................... 65 3.13 interrupt register description ........................................................................................... ...... 65 3.13.1 register description for interrup t ..................................................................................... 65 4. peripheral hardware ....................................................................................................................... 69 4.1 clock generator ........................................................................................................... ............ 69 4.1.1 overview ................................................................................................................ ........... 69 4.1.2 block diagram ................................................................................................................... 69 4.1.3 register map............................................................................................................. ........ 70 4.1.4 clock generator register description ............................................................................... 70 4.1.5 register description for clock generator .......................................................................... 70 4.2 bit ....................................................................................................................... .................... 72 4.2.1 overview ................................................................................................................ ........... 72 4.2.2 block diagram ................................................................................................................... 72 4.2.3 register map............................................................................................................. ........ 72 4.2.4 bit interval timer register description .............................................................................. 73 4.2.5 register description for bit interval timer ......................................................................... 73 4.3 wdt ....................................................................................................................... .................. 74 4.3.1 overview ................................................................................................................ ........... 74 4.3.2 block diagram ................................................................................................................... 74 4.3.3 register map............................................................................................................. ........ 74
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 3 4.3.4 watch dog timer register description .............................................................................. 75 4.3.5 register description for watch dog timer ......................................................................... 75 4.3.6 wdt interrupt timing waveform ....................................................................................... 76 4.4 wt ........................................................................................................................ ................... 77 4.4.1 overview ................................................................................................................ ........... 77 4.4.2 block diagram ................................................................................................................... 77 4.4.3 register map............................................................................................................. ........ 77 4.4.4 watch timer register description ..................................................................................... 77 4.4.5 register description for watch timer ................................................................................ 78 4.5 timer/pwm ................................................................................................................. ............. 80 4.5.1 8-bit timer/event counter 0, 1 .......................................................................................... 80 4.5.2 16-bit timer 4 .......................................................................................................... ......... 92 4.6 usart ..................................................................................................................... ................ 96 4.6.1 overview ................................................................................................................ ........... 96 4.6.2 block diagram ................................................................................................................... 97 4.6.3 clock generation ........................................................................................................ ...... 98 4.6.4 external clock (xck) .................................................................................................... .... 99 4.6.5 synchronous mode operation ........................................................................................... 99 4.6.6 data format ............................................................................................................. .......... 99 4.6.7 priority bit ............................................................................................................ ............ 100 4.6.8 usart transmitter ....................................................................................................... .. 100 4.6.9 usart receiver ............................................................................................................. 101 4.6.10 spi mode ............................................................................................................... ....... 104 4.6.11 register map ................................................................................................................. 106 4.6.12 usart register description ......................................................................................... 107 4.6.13 register description for usart .................................................................................... 107 4.6.14 baud rate setting (example) ......................................................................................... 11 0 4.7 i2c ....................................................................................................................... .................. 112 4.7.1 overview ................................................................................................................ ......... 112 4.7.2 block diagram ................................................................................................................. 112 4.7.3 i2c bit transfer ........................................................................................................ ....... 112 4.7.4 start / repeated start / stop ............................................................................. 113 4.7.5 data transfer .......................................................................................................... 113 4.7.6 acknowledge ............................................................................................................ 114 4.7.7 synchronization / arbitration ........................................................................... 114 4.7.8 operation ............................................................................................................... .... 115 4.7.9 register map............................................................................................................. ...... 123 4.7.10 i2c register description ............................................................................................... . 123 4.7.11 register description for i2c ...... ..................................................................................... 123 4.8 12-bit a/d converter ...................................................................................................... ........ 126 4.8.1 overview ................................................................................................................ ......... 126 4.8.2 block diagram ................................................................................................................. 127 4.8.3 adc operation ................................................................................................................ 128 4.8.4 register map............................................................................................................. ...... 129 4.8.5 adc register description ................................................................................................ 129 4.8.6 register description for adc ........................................................................................... 129 4.9 analog comparator ......................................................................................................... ....... 132 4.9.1 overview ................................................................................................................ ......... 132
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 4 4.9.2 block diagram ................................................................................................................. 132 4.9.3 in/out signal description ............................................................................................... 132 4.9.4 register map............................................................................................................. ...... 133 4.9.5 analog comparator register description ......................................................................... 133 4.9.6 register description for analog comparator ................................................................... 133 4.10 buzzer driver ............................................................................................................ ........... 134 4.10.1 overview ............................................................................................................... ........ 134 4.10.2 block diagram ............................................................................................................... 135 4.10.3 register map ................................................................................................................. 135 4.10.4 buzzer driver register description ................................................................................ 135 4.10.5 register description for buzzer driv er ........................................................................... 135 5. power down operation ....................................................................................................... ......... 137 5.1 overview .................................................................................................................. .............. 137 5.2 peripheral operation in idle/stop mode ............................................................................. 137 5.3 idle mode ................................................................................................................. ............ 137 5.4 stop mode ................................................................................................................. .......... 139 5.5 release operation of stop1, 2 mode ................................................................................... 140 5.5.1 register map............................................................................................................. ...... 140 5.5.2 power down operation register description ................................................................... 141 5.5.3 register description for power down operation.............................................................. 141 6. reset ...................................................................................................................... ................... 142 6.1 overview .................................................................................................................. .............. 142 6.2 reset source .............................................................................................................. ............ 142 6.3 block diagram ............................................................................................................. ........... 142 6.4 reset noise canceller ..................................................................................................... .... 142 6.5 power on reset ............................................................................................................ ...... 143 6.6 external resetb input ..................................................................................................... ..... 145 6.7 brown out detector processor .............................................................................................. . 146 6.7.1 register map............................................................................................................. ...... 148 6.7.2 reset operation register description ............................................................................. 148 6.7.3 register description for reset operation ........................................................................ 148 7. on-chip debug system ....................................................................................................... ......... 150 7.1 overview .................................................................................................................. .............. 150 7.1.1 description ............................................................................................................. ......... 150 7.1.2 feature ................................................................................................................. .......... 150 7.2 two-pin external interface ................................................................................................ ...... 151 7.2.1 basic transmission packet ............................................................................................... 151 7.2.2 packet transmission timing ............................................................................................. 152 7.2.3 connection of transmission ........ ..................................................................................... 153 8. memory programming ......................................................................................................... ......... 155 8.1 overview .................................................................................................................. .............. 155 8.1.1 description ............................................................................................................. ......... 155 8.1.2 features ................................................................................................................ .......... 155 8.2 flash and eeprom control and status register .................................................................... 155 8.2.1 register map............................................................................................................. ...... 155 8.2.2 register description for flash and eeprom .................................................................. 156 8.3 memory map ................................................................................................................ .......... 160 8.3.1 flash memory map ........................................................................................................ . 160
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 5 8.3.2 data eeprom memory map .......................................................................................... 161 8.4 serial in-system program mode ............................................................................................ 162 8.4.1 flash operation ......................................................................................................... ...... 162 8.4.2 data eeprom operation ................................................................................................ 16 6 8.4.3 summary of flash and data eeprom program/erase mode ........................................ 168 8.5 parallel mode ............................................................................................................. ............ 169 8.5.1 overview ................................................................................................................ ......... 169 8.5.2 parallel mode instruction format ...................................................................................... 1 70 8.5.3 parallel mode timing diagram .......................................................................................... 1 71 8.6 mode entrance method of isp and byte-parallel mode ........................................................... 171 8.6.1 mode entrance method for isp ....................................................................................... 171 8.6.2 mode entrance of byte-parallel ....................................................................................... 17 2 8.7 security .................................................................................................................. ................ 173 9. configure option ........................................................................................................... ................ 174 9.1 configure option control register ......................................................................................... . 174 9.2 serial id ................................................................................................................. ................ 175 10. appendix .................................................................................................................. ............... 176 10.1 instruction table ........................................................................................................ ........... 176 10.2 instructions on how to use the input port. ............................................................................. 1 79
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 6 list of figures figure 1.1 ocd debugger and pin configuration............................................................................... 14 figure 1.2 top abstract block diagram ......................................................................................... ..... 15 figure 1.3 10-ssop pin assignment diagram of Z51F0410hcx ...................................................... 16 figure 1.7 10-ssop package diagram ............................................................................................ .. 17 figure 1.8 usart pin location : usart_pinmode=0 .................................................................... 18 figure 1.9 usart pin location : usart_pinmode=1 .................................................................... 18 figure 1.10 i2c pin location : i2c_pinmode=0 ............................................................................... 19 figure 1.11 i2c pin location : i2c_pinmode=1 ............................................................................... 19 figure 1.12 external int pin location : eint_pinmode=0 .............................................................. 20 figure 1.13 external int pin location : eint_pinmode=1 .............................................................. 20 figure 1.14 buzzer out pin location : buzo _pinmode=0 .............................................................. 20 figure 1.15 buzzer out pin location : buzo _pinmode=1 .............................................................. 21 figure 1.16 timer out pin location : tmr_pinmode=0 ................................................................... 21 figure 1.17 timer out pin location : tmr_pinmode=1 ................................................................... 21 figure 1.18 super lock enabled encryption/dec ryption diagram ...................................................... 22 figure 1.19 general purpose i/o port .......................................................................................... ...... 23 figure 1.20 external interrupt i/o port ....................................................................................... ......... 24 figure 1.21 xin(subxin) / an0 /rxd /p0[0] port structure .............................................................. 25 figure 1.22 xout(subxout) / an1 / int1 / txd / p0[1] port structure .......................................... 26 figure 1.23 resetb / an2 / ack / p0[2] port structure .................................................................... 27 figure 1.24 p0[3] / int0 / ss / ec0 / an3 / acout port structure ................................................... 29 figure 1.25 p0[4]/scl/t0o/an4/ac-/avref port diagram .................................................................. 31 figure 1.26 p0[5]/sda/pwm1o/buz/an5/ac+ port structure .......................................................... 33 figure 1.27 p0[6] / an6, p0[7] / an7 port structure ........................................................................... 35 figure 1.28 ac timing ......................................................................................................... .............. 40 figure 2.1 program memory ..................................................................................................... .......... 42 figure 2.2 data memory map .................................................................................................... ......... 43 figure 2.3 lower 128 bytes ram ................................................................................................ ....... 44 figure 2.4 debounce function .................................................................................................. ......... 55 figure 3.1 external interrupt description ..................................................................................... ....... 57 figure 3.2 block diagram of interrupt ......................................................................................... ........ 58 figure 3.3 interrupt vector address tabl e ..................................................................................... ..... 60 figure 3.4 effective timing of interrupt enable register ................................................................... 6 1 figure 3.5 effective timing of interrupt flag register ........................................................................ . 61 figure 3.6 execution of multi interrupt ....................................................................................... ......... 62 figure 3.7 interrupt response timing diagram .................................................................................. 63 figure 3.8 correspondence between vector table address and the entry address of isp ................. 63 figure 3.9 saving/restore process diagram & sample source ......................................................... 63 figure 3.10 timing chart of interrupt acceptance and interrupt return instruction ............................. 64 figure 4.1 clock generator block diagram ...................................................................................... .. 69 figure 4.2 bit block diagram .................................................................................................. .......... 72 figure 4.3 wdt block diagram .................................................................................................. ........ 74 figure 4.4 wdt interrupt timing waveform ...................................................................................... . 76 figure 4.5 watch timer block diagram .......................................................................................... .... 77 figure 4.6 8 bit timer/event counter0, 1 block diagram ................................................................... 81 figure 4.7 timer/event counter0, 1 example .................................................................................... . 82
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 7 figure 4.8 operation example of timer/event counter0, 1 ................................................................ 82 figure 4.9 16 bit timer/event counter0, 1 block diagram ................................................................. 83 figure 4.10 8-bit capture mode for timer0, 1 .................................................................................. ... 84 figure 4.11 input capture mode operation of timer 0, 1 ................................................................... 85 figure 4.12 express timer overflow in capture mode ....................................................................... 85 figure 4.13 16-bit capture mode of timer 0, 1 ................................................................................. .. 86 figure 4.14 pwm mode ...................................................................................................................... 87 figure 4.15 example of pwm at 4mhz ............................................................................................ .. 87 figure 4.16 example of changing the period in absolute duty cycle at 4mhz ................................... 88 figure 4.17 timer4 16-bit mode block diagram ................................................................................. 93 figure 4.18 usart block diagram ............................................................................................... ..... 97 figure 4.19 clock generation block diagram ..................................................................................... 98 figure 4.20 synchronous mode xckn timing. ................................................................................... 9 9 figure 4.21 frame format ...................................................................................................... ............ 100 figure 4.22 start bit sampling ................................................................................................ .......... 103 figure 4.23 sampling of data and parity bit ................................................................................... .. 104 figure 4.24 stop bit sampling and next start bit sampling ............................................................. 104 figure 4.25 spi clock formats when ucpha=0 .............................................................................. 105 figure 4.26 spi clock formats when ucpha=1 .............................................................................. 106 figure 4.27 i2c block diagram ................................................................................................. ....... 112 figure 4.28 bit transfer on the i2c-bus ....................................................................................... .... 113 figure 4.29 start and stop condition ......................................................................................... 113 figure 4.30 data transfer on the i2c-bu s ...................................................................................... .. 114 figure 4.31 acknowledge on the i2c-bus ........................................................................................ 114 figure 4.32 clock synchronization during arbi tration procedure ...................................................... 115 figure 4.33 arbitration procedure of two masters ........................................................................... 11 5 figure 4.34 formats and states in the master transmitter mode ..................................................... 117 figure 4.35 formats and states in the master receiver mode ......................................................... 119 figure 4.36 formats and states in the slave transmitter mode ....................................................... 121 figure 4.37 formats and states in the slave receiver mode ........................................................... 123 figure 4.38 adc block diagram.................................................................................................. ..... 127 figure 4.39 a/d analog input pin connecting capacitor .................................................................. 127 figure 4.40 a/d power(avdd) pin connecting capacitor ................................................................ 127 figure 4.41 adc operation for align bit ....................................................................................... .... 128 figure 4.42 a/d converter operation flow ....................................................................................... 128 figure 4.43 analog comparator block diagram ............................................................................... 132 figure 5.1 idle mode release timing by external interrupt ............................................................ 138 figure 5.2 stop mode release timing by external interrupt .......................................................... 139 figure 5.3 stop1, 2 mode release flow ........................................................................................ 140 figure 6.1 reset block diagram ................................................................................................ .... 142 figure 6.2 reset noise canceller time diagram ................................................................................. 143 figure 6.3 fast vdd rising time................................................................................................ ........ 143 figure 6.4 internal reset release timing on power-up ............................................................... 143 figure 6.5 configuration timing when power-on ............................................................................... 1 44 figure 6.6 boot process wave form ................................................................................................ 145 figure 6.7 timing diagram after reset ......................................................................................... . 146 figure 6.8 oscillator generating waveform example ......................................................................... 146 figure 6.9 block diagram of bod ............................................................................................... ..... 147
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 8 figure 6.10 internal reset at the power fail situation ........................................................................ 148 figure 6.11 configurati on timing when bod reset ........................................................................ 148 figure 7.1 block diagram of on-chip debug system ....................................................................... 150 figure 7.2 10-bit transmission packet ......................................................................................... ...... 151 figure 7.3 data transfer on the twin bus ...................................................................................... ..... 152 figure 7.4 bit transfer on the serial bus ..................................................................................... ....... 152 figure 7.5 start and stop condition ........................................................................................... ........ 152 figure 7.6 acknowledge on the serial bus ...................................................................................... .. 153 figure 7.7 clock synchronization during wait procedure .................................................................. 153 figure 7.8 connection of transmission ......................................................................................... .... 154 figure 8.1 flash memory map ................................................................................................... ....... 160 figure 8.2 address configuration of flash memory .......................................................................... 160 figure 8.3 data eeprom memory map........................................................................................... 16 1 figure 8.4 address configuration of data eeprom .......................................................................... 161 figure 8.5 the sequence of page program and erase of flash memory .......................................... 162 figure 8.6 the sequence of bulk erase of flash memory ................................................................. 163 figure 8.7 pin diagram for parallel programming .............................................................................. 169 figure 8.8 parallel byte read timing of program memory ............................................................... 171 figure 8.9 parallel byte write timing of program memory ............................................................... 171 figure 8.10 isp mode ......................................................................................................... ............ 172 figure 8.11 byte-parallel mode (10pin package only) ....................................................................... 172
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 9 list of tables table 1.1 ordering information of the Z51F0410 mcu ....................................................................... 12 table 1.2 absolute maximum ratings ............................................................................................ .... 36 table 1.3 recommended operation conditions ................................................................................. 36 table 1.4 a/d converter characteristics ....................................................................................... ..... 36 table 1.5 voltage dropout converter characteristics ......................................................................... 37 table 1.6 power-on reset characteristics ......................................................................................... 37 table 1.7 brown out detector characteristics .................................................................................... 38 table 1.8 internal 8mhz rc oscillator characte ristics ....................................................................... 3 8 table 1.9 internal 128khz rc oscillator charac teristics .................................................................... 38 table 1.10 dc electrical characteristics ...................................................................................... ...... 38 table 1.11 ac characteristics ................................................................................................. ........... 39 table 1.12 dc characteristics ................................................................................................. ........... 39 table 1.13 ac characteristics ................................................................................................. ........... 40 table 2.1 sfr map summary ..................................................................................................... ....... 45 table 2.2 sfr map ............................................................................................................. ............... 46 table 2.3 register map ........................................................................................................ .............. 52 table 3.1 interrupt group priority level ...................................................................................... ........ 56 table 3.2 interrupt vector address table ...................................................................................... ..... 59 table 3.3 register map ........................................................................................................ .............. 65 table 4.1 sscr register map ................................................................................................... ........ 70 table 4.2 bit register map .................................................................................................... ............ 72 table 4.3 wdt register map .................................................................................................... ......... 74 table 4.4 wt register map ..................................................................................................... ........... 77 table 4.5 operating modes of timer ............................................................................................ ...... 80 table 4.6 pwm frequency vs. resolution at 8 mhz ........................................................................... 86 table 4.7 timer register map .................................................................................................. .......... 88 table 4-8 register map ........................................................................................................ .............. 93 table 4.9 equations for calculating baud rate register setting ........................................................ 98 table 4.10 cpol functionality ................................................................................................. ........ 105 table 4.11 usart register map ................................................................................................. .... 106 table 4.12 examples of ubaud settings for commonly used oscillator frequencies .................... 110 table 4.13 examples of ubaud settings for commonly used oscillator frequencies (continued) . 111 table 4.14 examples of ubaud settings for commonly used oscillator frequencies (continued) . 111 table 4.15 i2c register map ................................................................................................... ......... 123 table 4.16 adc register map ................................................................................................... ....... 129 table 4.17 analog comparator register map .................................................................................. 13 3 table 5.1 peripheral operation during power down mode. .............................................................. 137 table 5.2 pcon register map ................................................................................................... ...... 140 table 6.1 reset state ......................................................................................................... .............. 142 table 6.2 boot process description ............................................................................................ ..... 145 table 6.3 bod register map .................................................................................................... ....... 148 table 8-1 flash and eeprom register map ................................................................................... 155 table 8-2 flash and data eeprom operation mode ...................................................................... 168 table 8-3 the selection of memory type by addrh[7:4] ................................................................. 169 table 8-4 parallel mode instruction form at .................................................................................... ... 170 table 8-5 control pin description ............................................................................................. ........ 171
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 10 table 8-6 security policy using lock-bits ..................................................................................... ...... 173 table 9-1 summary of sid ...................................................................................................... ......... 175
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 11 Z51F0410 cmos single-chip 8-bit microcontroll er with 12-bit a/d converter 1. overview 1.1 description the Z51F0410 mcu is advanced cmos 8-bit microcontro ller with 4k bytes of flash. this is powerful microcontroller which provides a highly flexible and cost effective solution to many embedded control applications. this provides the following features : 4k bytes of flash, 256 bytes of ram, 256 bytes of data eeprom, general purpose i/o, 8/16-bit timer/co unter, watchdog timer, watch timer, usart, buzzer, i2c, on-chip por, 12-bit a/d converter, analog comparator, 10-bit pwm output, on-chip oscillator and clock circuitry. the Z51F0410 mcu also supports power saving modes to reduce power consumption. device name flash ram adc i/o port package Z51F0410 4k bytes 256 bytes 8 channel 8 10 ssop 1.2 features ? cpu - 8 bit cisc core (8051 compatible,2 clock per cycle) ? 4k bytes on-chip flash - endurance : 10,000 times - retention : 10 years - code encryption (super lock) ? 256 bytes sram ? 256 bytes data eeprom - mapped in xdata region - endurance : 100,000 times - retention : 10 years ? general purpose i/o - 8 ports (p0[7:0]) ? one basic interval timer -reset release time - 16ms, 32ms, 64ms configurable ? timer/ counter - 8bit2ch(16bit1ch) - 16bit x 1ch ? 10-bit pwm (using timer1) - 10bitx1ch ? watch dog timer ? watch timer ? usart ? buzzer ? i2c ? 12 bit a/d converter - 8 input channels ? analog comparator - on chip analog comparator with acout ? interrupt sources - external (2)
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 12 - pin change interrupt(p0) (1) - usart (2) - timer (3) - i2c (1) - adc (1) - acom (1) - wdt (1) - wt (1) - bit (1) - data eeprom(1) ? on-chip rc-oscillator - 8mhz(1%) @ 25  - 128khz(50%) ? power on reset - 1.4v ? programmable brown-out detector - 4 level selectable ? reconfigurable secondary pin function ? minimum instruction execution time - 250ns (@8mhz, nop instruction) ? power down mode - idle, stop1, stop2 mode ? sub-active mode - system used external 32.768khz crystal or system used internal 128khz oscillator ? operating frequency - 1mhz ~ 8mhz ? operating voltage - 1.8v ~ 5.5v (@ 1~8mhz) - 2.2v ~ 5.5v (@ 1~8mhz, using comparator) ? operating temperature : -40 ~ +85 ? package type - 10-pin ssop - pb free package 1.3 ordering information table 1.1 ordering information of the Z51F0410 mcu device name rom size ram size eeprom size package Z51F0410hcx 4k bytes flash 256 bytes 256 bytes 10ssop
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 13 1.3.1 part number suffix designation zilog part numbers consist of a number of components, as indicated in the following example. example: part number Z51F0410hcx is an 8-bit mcu with 4 kb of flash memory and 256 bytes of ram in a 10-pin ssop package and operating within a ?40c to +85c temperature range. in accordance with rohs standards, this device has been built using lead-free solder. z51 f 04 10 h c x temperature range x = ?40c to +85c pin count c = 10 pins package h = ssop device type flash memory size 04 = 4 kb flash flash memory f = general-purpose flash device family z51 = z8051 8-bit core mcu 1.4 development tools 1.4.1 compiler zilog does not provide any compiler for the Z51F0410 mcu. but the cpu core of the Z51F0410 mcu is mentor 8051, you can use all kinds of third party?s standard 8051 compiler like keil c compiler, open source sdcc (small device c compiler) .. these compilers? output debug information can be integrated with our ocd emulator and debugger. refer to ocd manual for more details. 1.4.2 ocd emulator and debugger the ocd (on chip debug) emulator supports zilog?s 8051 series mcu emulation. the ocd interface uses two wires interfacing between pc and mcu which is attached to user?s system. the ocd can read or change the value of mcu?s internal memory and i/o peripherals. and also the ocd controls mcu?s internal debugging logic, it means ocd cont rols emulation, step run, monitoring, etc. the ocd debugger program works on microsoft-windows nt, 2000, xp, vista(32-bit) operating system.
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 14 if you want to see details more, please refer to ocd debugger manual. you can download debugger s/w and manual from out web-site. the connection pins between pc and mcu is as follows: sclk (p0[3] of Z51F0410) sdata (p0[5] of Z51F0410) ocd connector diagram: connect ocd and user system note: p0[3] is pulled-up by external resistor to avoid malfunction when power is on. figure 1.1 ocd debugger and pin configuration 2 user vcc 4 user gnd 6 sclk 8 sdata 10 1 3 5 7 9
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 15 1.5 block diagram note) p01, p02, p03 pin are programmable or configure option selectable. figure 1.2 top abstract block diagram on ?chip debug p03/dscl m8051 core eeprom (256b) ram (256b) flash (4k byte) power on reset brown out detector int-rc osc 8mhz ( 1%) voltage down convertor p0 port bit wdt wt clock/ system con timer & pwm interrup controller usart i2c 12-bit adc p05/dsda p05/an5 avref/p04/an4 p03/an3 p02/an2 p01/an1 p00/an0 p03/ec0 p05/t1(pwm1) p04/t0o p01/int0 p04/int1 p03/ss p02/ack p01/txd p00/rxd p05/sda p04/scl p07~p00 subxin/p00 subxout/p01 xin/p00 xout/p01 resetb/p02 vdd vss p07/an7 p06/an6 analog comparator buzzer p05/ac+ p04/ac- p03/acout p05/buzo decryption int-rc osc 128khz ( 50%)
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 16 1.6 pin assignment note) - if 8 pin pkg, pin 5 and 6 are removed in 10 pin pkg. - on on-chip debugging, isp uses p0[3], p0[5] pin as dscl, dsda. - p00, p01,p02,p06 pin priority is high from left to right. p05, p04,p03,p07 pin priority is high from right to left. figure 1.3 10-ssop pin assignment diagram of Z51F0410hcx 1 2 3 4 5 6 7 8 9 10 vdd xin(subxin) / an0 / rxd / p00 xout(subxout) / an1 / int1 / txd / p01 resetb / an2 / ack / p02 an6 / p06 z 5 1 f 0 4 1 0 h c vss p05 / sda / pwm1o / buz / an5 / ac+ / (dsda) p04 / scl / t0o / an4 / ac- / avref p03 / int0 / ss / ec0 / an3 / acout / (dscl) p07 / an7 t pin priority high t pin priority high
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 17 1.7 package diagram figure 1.4 10-ssop package diagram
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 18 1.8 reconfigurable pin description 1.8.1 usart pin location switch mode 1.8.2 i2c pin location switch mode figure 1.6 usart pin location : usart_pinmode=1 1 2 3 4 5 6 7 8 9 10 vdd xin(subxin) / an0 / p00 xout(subxout) / an1 / int1 / p01 resetb / an2 / ack / p02 an6 / rxd / p06 z 5 1 f 0 4 1 0 h c vss p05 / sda / pwm1o / buz / an5 / ac+ / (dsda) p04 / scl / t0o / an4 / ac- / avref p03 / int0 / ss / ec0 / an3 / acout / (dscl) p07 / txd / an7 t pin priority high t pin priority high figure 1.5 usart pin location : usart_pinmode=0 1 2 3 4 5 6 7 8 9 10 vdd xin(subxin) / an0 / rxd / p00 xout(subxout) / an1 / int1 / txd / p01 resetb / an2 / ack / p02 an6 / p06 z 5 1 f 0 4 1 0 h c vss p05 / sda / pwm1o / buz / an5 / ac+ / (dsda) p04 / scl / t0o / an4 / ac- / avref p03 / int0 / ss / ec0 / an3 / acout / (dscl) p07 / an7 t pin priority high t pin priority high
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 19 1.8.3 external interrupt pin location switch mode 1 2 3 4 5 6 7 8 9 10 vdd xin(subxin) / an0 / rxd / p00 xout(subxout) / an1 / int1 / txd / p01 resetb / an2 / ack / p02 an6 / p06 z 5 1 f 0 4 1 0 h c vss p05 / sda / pwm1o / buz / an5 / ac+ / (dsda) p04 / scl / t0o / an4 / ac- / avref p03 / int0 / ss / ec0 / an3 / acout / (dscl) p07 / an7 t pin priority high t pin priority high figure 1.8 i2c pin location : i2c_pinmode=1 figure 1.7 i2c pin location : i2c_pinmode=0 1 2 3 4 5 6 7 8 9 10 vdd xin(subxin) / an0 / rxd / p00 xout(subxout) / an1 / int1 / txd / p01 resetb / an2 / ack / p02 an6 / p06 z 5 1 f 0 4 1 0 h c vss p05 / sda / pwm1o / buz / an5 / ac+ / (dsda) p04 / scl / t0o / an4 / ac- / avref p03 / int0 / ss / ec0 / an3 / acout / (dscl) p07 / an7 t pin priority high t pin priority high 1 2 3 4 5 6 7 8 9 10 vdd xin(sxin) / an0 / rxd / p00 xout(sxout) / an1 / int1 / txd / p01 resetb / an2 / ack / p02 an6 / scl / p06 z 5 1 f 0 4 1 0 h c vss p05 / pwm1o / buz / an5 / ac+ / (dsda) p04 / t0o / an4 / ac- / avref p03 / int0 / ss / ec0 / an3 / acout / (dscl) p07 / sda / an7 t pin priority high t pin priority high
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 20 1.8.4 buzzer out pin location switch mode 1 2 3 4 5 6 7 8 9 10 vdd xin(subxin) / an0 / rxd / p00 xout(subxout) / an1 / int1 / txd / p01 resetb / an2 / ack / p02 an6 / buz / p06 z 5 1 f 0 4 1 0 h c vss p05 / sda / pwm1o / an5 / ac+ / (dsda) p04 / scl / t0o / an4 / ac- / avref p03 / int0 / ss / ec0 / an3 / acout / (dscl) p07 / an7 t pin priority high t pin priority high figure 1.11 buzzer out pin location : buzo_pinmode=0 1 2 3 4 5 6 7 8 9 10 vdd xin(subxin) / an0 / rxd / p00 xout(subxout) / an1 / int1 / txd / p01 resetb / an2 / ack / p02 an6 / p06 z 5 1 f 0 4 1 0 h c vss p05 / sda / pwm1o / buz / an5 / ac+ / (dsda) p04 / scl / t0o / an4 / ac- / avref p03 / int0 / ss / ec0 / an3 / acout / (dscl) p07 / an7 t pin priority high t pin priority high figure 1.10 external int pin location : eint_pinmode=1 figure 1.9 external int pin location : eint_pinmode=0 1 2 3 4 5 6 7 8 9 10 vdd xin(subxin) / an0 / rxd / p00 xout(subxout) / an1 / txd / p01 resetb / an2 / ack / p02 an6 / int1 / p06 z 5 1 f 0 4 1 0 h c vss p05 / sda / pwm1o / buz / an5 / ac+ / (dsda) p04 / scl / t0o / an4 / ac- / avref p03 / ss / ec0 / an3 / acout / (dscl) p07 / int0 / an7 t pin priority high t pin priority high
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 21 1.8.5 timer pin location switch mode 1.9 code encryption (super lock) basically user code data will be programmed with raw data in flash area. although code data read mode is protected with lock mode, its contents are vulnerable for several codes hooking method. we provide the code encryption method to secure the user code data. the original user code will be scrambled with user seed key value (private key). the scrambled data is programmed in flash area. the fetched code during cpu operation will be decoded with the user key in configuration area. figure 1.14 timer out pin location : tmr_pinmode=1 1 2 3 4 5 6 7 8 9 10 vdd xin(sxin) / an0 / rxd / p00 xout(sxout) / an1 / int1 / txd / p01 resetb / an2 / ack / ec0 / p02 an6 / pwm1o / p06 z 5 1 f 0 4 1 0 h c vss p05 / sda / buz / an5 / ac+ / (dsda) p04 / scl / an4 / ac- / avref p03 / int0 / ss / an3 / acout / (dscl) p07 / t0o / an7 t pin priority high t pin priority high figure 1.13 timer out pin location : tmr_pinmode=0 1 2 3 4 5 6 7 8 9 10 vdd xin(subxin) / an0 / rxd / p00 xout(subxout) / an1 / int1 / txd / p01 resetb / an2 / ack / p02 an6 / p06 z 5 1 f 0 4 1 0 h c x vss p05 / sda / pwm1o / buz / an5 / ac+ / (dsda) p04 / scl / t0o / an4 / ac- / avref p03 / int0 / ss / ec0 / an3 / acout / (dscl) p07 / an7 t pin priority high t pin priority high figure 1.12 buzzer out pin location : buzo_pinmode=1
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 22 figure 1.15 super lock enabled encryption/decryption diagram 00011010 00000000 11110010 00110000 10101101 11100111 01001101 10101011 flash / eeprom core bus encryption download decryption user key user key config option original code scrambled code
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 23 1.10 port structure 1.10.1 general purpose i/o port figure 1.16 general purpose i/o port vdd vdd vdd pad sub-func enable levelshift ( 1.8v to extvdd) levelshift (extvdd to 1.8v) data register open drain register pull-up register sub-func data output direction register sub-func direction 0 1 mux mux 0 1 0 1 mux r d cp q debounce clk debounce enable portx input sub-func data input analog channel enable analog input analog input (without resistor) r(400 ) cmos or schmittlevel input mux 0 1 padx data input
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 24 1.10.2 external interrupt i/o port figure 1.17 external interrupt i/o port vdd vdd vdd pad sub-func enable levelshift ( 1.8v to extvdd) levelshift (extvdd to 1.8v) data register open drain register pull-up register sub-func data output direction register sub-func direction 0 1 mux mux 0 1 0 1 mux r d cp q debounce clk debounce enable sub-func data input analog channel enable analog input 0 1 mux r d cp q vdd external interrupt interrupt enable edge reg flag clear polarity reg r(200 ) cmos or schmittlevel input portx input mux 0 1 padx data input r(200 )
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 25 1.11 port structure diagram (detail view) 1.11.1 p0[0] port structure the pull-up resister is directly controlled by the pull-up register bit regardless of current port direction. the open-drain control is also by open-drain register. on open-drain mode, the push-pull drives just n-mos. when the direction is output (value 1), the output pad voltage is controlled by push-pull driver for the current output data. the secondary input or analog channel selection bit disable the output direction regardless of the current direction register. the secondary input rxd_en, pci_en[0] enables the input data path continuously. on normal read mode (non secondary mode), the input data path is only enabled during the cpu oeb (active low). when the analog channel (an0) is enabled, the first input gate from the pad is disabled (highes t priority) to prevent the input leakage current for the floating voltage status. the xin function disables all analog channels and secondary input/output. at read operation, the input data is selected by pa d direction register. if its value is ?1?, it reads the current output register value. otherwise, it reads the current pad voltage directly (just during oeb active). in addition, always the current pad voltage is read by pad data register. figure 1.18 xin(subxin) / an0 /rxd /p0[0] port structure xin(subxin) / a n0 / rxd(txd) / p00 vdd vdd direction output data pull-up enable open-drain p0da_oeb an0_en (from psr) an0 rxd_in_en rxd xin(subxin) xin_en (from config) 0 1 txd_out rxd_out_en output input secondary input analog input pad data lpf pci_en[0] pci_in[0] nc20ns 1 0 data p0rda_oeb
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 26 1.11.2 p0[1] port structure the figure 1.19 shows a brief diagram of p0[1] port structure. the pull-up resister is directly controlled by the pull-up register bit regardless of current port direction. the open-drain control is also by open-drain register. on open-drain mode, the push-pull drives just n-mos. when the direction is output (value 1), the output pad voltage is controll ed by push-pull driver for the current output data. the secondary input or analog channel selection bit disable the output direction regardless of the current direction register. the secondary input int1_en, pci_en[1] enables the input data path continuously. on normal read mode (non secondary mode), the input data path is only enabled during the cpu oeb (active low). when the analog channel (an1) is enabled, the first input gate from the pad is disabled (highest priority) to prevent the input leakage current for the floating voltage status. the xout function disables all analog channels and secondary input/output. at read operation, the input data is selected by pad direction register. if its value is ?1?, it reads the current output register value. otherwise, it reads the current pad voltage directly (just during oeb active). in addition, always the current pad voltage is read by pad data register. figure 1.19 xout(subxout) / an1 / int1 / txd / p0[1] port structure xout(subxout) / an1 / int1 / t xd(rxd) / p01 vdd vdd data direction output data pull-up enable open-drain 1 0 an1_en an1 ext_int1 ext_int1_en xout(subxout) xout_en (from config) txd_out_en txd txd_in_en rxd output input secondary input analog input lpf 0 1 nc20ns pad data pci_en[1] pci_in[1] p0da_oeb p0rda_oeb
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 27 1.11.3 p0[2] port structure if the resetb_en (from config data) is 1, the inpu t secondary data path is enabled with the highest priority level and it automatically enables the pull-up function regardless of pull-up register value. the analog channel selection bit enables the path of the an2 and disable normal logic data path to prevent the input gate leakage current. when the direction register value is 0, the input data is always external pad voltage. the pull-up resister is directly controlled by the pull-up register bit regardless of current port direction. the open-drain control is also by open-drain register. on open-drain mode, the push-pull drives just n-mos. when the direction is output (value 1), the output pad voltage is controlled by push-pull driver for the current output data. the secondary input or analog channel selection bit disable the output direction regardless of the current direction register. the secondary input ack_in_en, pci_en[2] enable the input data path continuously. on normal read mode (non secondary mode), the input data path is only enabled during the cpu oeb (active low). when the analog channel (an2) is enabled, the first input gate from the pad except of reset enabled is disabled (highest priority) to prevent the input leakage current for the floating voltage status. at read operat ion, the input data is selected by pad direction register. if its value is ?1?, it reads the current output register value. figure 1.20 resetb / an2 / ack / p0[2] port structure resetb / an2 / a ck / p0[2] vdd vdd data direction output data pull-up enable open-drain 1 0 an2_en an2 ack_in_en ack_in ack_out_en ack_out 0 1 resetb_en (from config) output input secondary input analog input resetb_en resetb lpf p0da_oeb p0rda_oeb pci_en[2] pci_in[2] pad data
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 28 otherwise, it reads the current pad voltage directly (just during oeb active). in addition, always the current pad voltage is read by pad data register.
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 29 1.11.4 p0[3] port structure the pull-up resister is directly controlled by the pull-up register bit regardless of current port direction. the open-drain control is also by open-drain register. on open-drain mode, the push-pull drives just n-mos. the ocd mode enable the open-drain output regardless of the open-drain register value. when the direction is output (value 1), the output pad voltage is controlled by push-pull driver for the current output data. the secondary input or analog channel selection bit disable the output direction regardless of the current direction register. the secondary input ss_en, int0_en, ec0_en, pci_en[3] enable the input data path continuously. on normal read mode (non secondary mode), the input data path is only enabled during the cpu oeb (active low). when the analog channel (an3) is enabled, the first input gate from the pad is disabled (highest priority) to prevent the input leakage current for the floating voltage status. at read operation, the input data is selected by pad direction figure 1.21 p0[3] / int0 / ss / ec0 / an3 / acout port structure p03 / int0 / ss / ec0 / an3 / a cout / (dscl) vdd vdd data direction output data open-drain 1 0 int0_en int0 ss_out_en ss_out 0 1 ec0_en ec0 ss_in_en ss an3_en an3 pull-up enable ocd_en aco_out_en aco_out 0 1 output input secondary input analog input lpf nc20ns nc20ns p0da_oeb p0rda_oeb pad data pci_en[3] pci_in[3]
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 30 register. if its value is ?1?, it reads the current outp ut register value. otherwise, it reads the current pad voltage directly (just during oeb active). in addition, always the current pad voltage is read by pad data register.
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 31 1.11.5 p0[4] port structure the pull-up resister is directly controlled by the pull-up register bit regardless of current port direction. the open-drain control is also by open-drain register. on open-drain mode, the push-pull drives just n-mos. the i2c mode enable the open-drain output regardless of the open-drain register value. when the direction is output (value 1), the output pad voltage is controlled by push-pull driver for the current output data. the secondary input or analog channel selection bit disable the output direction regardless of the current direction register. the secondary input scl_in_en, pci_en[4] enables the input data path continuously. on normal read mode (non secondary mode), the input data path is only enabled during the cpu oeb (active low). when the analog channel (an4,ac-) is enabled, the first input gate from the pad is disabled (highest pri ority) to prevent the input leakage current for the floating voltage status. the avref function disables all analog channels and secondary figure 1.22 p0[4]/scl/t0o/an4/ac-/avref port diagram p04 / scl / t0o / a n4 / ac- / avref vdd vdd data direction output data pull-up enable open-drain 1 0 i2c_en scl_out 0 1 i2c_en scl_in ac- en ac- avref_en avref an4_en an4 0 1 t0o t0o_en i2c_en pin_mode0 output input secondary input analog input lpf p0da_oeb p0rda_oeb pad data pci_en[4] pci_in[4]
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 32 input/output.at read operation, the input data is select ed by pad direction register. if its value is ?1?, it reads the current output register value. otherwise, it reads the current pad voltage directly (just during oeb active). in addition, always the current pad voltage is read by pad data register.
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 33 1.11.6 p0[5] port structure the pull-up resister is directly controlled by the pull-up register bit regardless of current port direction. the open-drain control is also by open-drain register. on open-drain mode, the push-pull drive just n- mos. the i2c mode and ocd mode enable the open-drain output regardless of the open-drain register value. when the direction is output (value 1), the output pad voltage is controlled by push- pull driver for the current output data. the secondary input or analog channel selection bit disable the output direction regardless of the current direction register. the secondary input sda_in_en, pci_en[5] enables the input data path continuously. on normal read mode (non secondary mode), the input data path is only enabled during the cp u oeb (active low). when the analog channel (an5) is enabled, the first input gate from the pad is disabled (highest priority) to prevent the input leakage current for the floating voltage status. the ac+ function disables all analog channels and secondary input/output. at read operation, the input data is selected by pad direction register. if its value is ?1?, it figure 1.23 p0[5]/sda/pwm1o/buz/an5/ac+ port structure p0[5]/sda/pwm1 o/buz/an5/ac+ vdd vdd data direction output data open-drain 1 0 i2c_en sda_out 0 1 i2c_en sda_in an5_en an5 ac+ en ac+ 0 1 pwm1o pwm1o_en 0 1 buzo_en buzo pull-up enable i2c_en pin_mode0 lpf output input secondary input analog input ocd_en p0da_oeb p0rda_oeb pad data pci_en[5] pci_in[5]
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 34 reads the current output register value. otherwise, it reads the current pad voltage directly (just during oeb active). in addition, always the current pad voltage is read by pad data register.
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 35 1.11.7 p0[6]/p0[7] port structure the analog channel selection bit enables the path of the an6/an7 and disable normal logic data path to prevent the input gate leakage current. when the direction register value is 0, the input data is always external pad voltage. the pull-up resister is directly controlled by the pull-up register bit regardless of current port direction. the open-drain control is also by open-drain register. on open-drain mode, the push-pull drives just n-mos. when the direction is output (value 1), the output pad voltage is controlled by push-pull driver for the current output data. the secondary input pci_en[6]/pci_en[7] enable the input data path continuously. on normal read mode (non secondary mode), the input data path is only enabled during the cpu oeb (active low). when the analog channel (an6/an7) is enabled, the first input gate from the pad is disabled (highest priority) to prevent the input leakage current for the floating voltage status. at read operation, the input data is selected by pad direction register. if its value is ?1?, it reads the current output register value. otherwise, it reads the current pad voltage directly (just during oeb active). in addition, always the current pad voltage is read by pad data register. figure 1.24 p0[6] / an6, p0[7] / an7 port structure r0[6]/an6 p0[7]/an7 vdd vdd data direction output data pull-up enable open-drain 1 0 an6/an7 an6_en/an7_en fuse_pkg8 (from config) output input analog input lpf p0da_oeb p0rda_oeb pci_en[6]/pci_en[7] pci_in[6]/pci_in[7] secondary pad data
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 36 1.12 electrical characteristics 1.12.1 absolute maximum ratings table 1.2 absolute maximum ratings parameter s y mbol ratin g unit supply voltage vdd -0.3~+6.5 v vss -0.3~+0.3 v normal voltage pin vi -0.3~vdd+0.3 v vo -0.3~vdd+0.3 v ioh 10 ma ioh 80 ma iol 20 ma iol 160 ma total power dissipation pt 600 mw storage temperature tstg -45~+125  note) stresses beyond those listed under ?absolute maximum ratings? may cause permanent damage to the device. this is a stress rating only and functional operation of the device at any other conditions beyond those indicated in the operational sections of this specification is not implied. exposure to absolute maximum rating conditions for extended periods may affect device reliability. 1.12.2 recommended operating conditions table 1.3 recommended operation conditions parameter symbol condition min typ max unit supply voltage vdd fxin=1.0~8mhz 1.8 - 5.5 v fsub=32.768khz operating temperature topr vdd=1.8~5.5v -40 - 85  operating frequency fopr fxin 1 - 8 mhz fsub - 32.768 - khz internal rc-osc - 8 - mhz 1.12.3 a/d converter characteristics (ta=-40 ~ +85 , vdd=avdd=1.8v ~ 5.5v, vss=0v) table 1.4 a/d converter characteristics parameter symbol condition min typ max unit resolution - - 12 - bits total accuracy avdd=vdd=5.12 v fxin=4mhz - 3(avref base) lsb integral linear error inl - - 3 lsb differential linearity error dle - - 2 lsb zero offset error zoe - 3 lsb full scale error fse - 3 lsb
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 37 conversion time tcon 12bit conversion max 3mhz - 60 - cycl e analog input voltage van - vss - avdd=vd d v analog power voltage avdd - - *avdd=v dd - v analog reference voltage avref - 2.0 - avref=a vdd v analog ground voltage avss - - vss - v analog input leakage current avdd=vdd=5.12 v - - 10 ua adc operating current idd avdd=vdd=5.12 v - 1 3 ma sidd - - 1 ua 1.12.4 voltage dropout converter characteristics table 1.5 voltage dropout converter characteristics parameter symbol condition min typ max unit operating voltage - 1.8 - 5.5 v operating temperature - -40 - +85 regulation voltage - 1.62 1.8 1.98 v drop-out voltage - - - 0.02 v current drivability run/idle - 10 - ma sub-active - 1 - ma stop1 - 50 - ua stop2 - 10 - ua operating current idd1 run/idle - - 1 ma idd2 sub-active - - 0.1 ma sidd1 stop1 - - 5 ua sidd2 stop2 - - 0.1 ua drivability transition time tran1 sub to run - - 1 us tran2 stop to run - - note) -stop1: wdt running - stop2: wdt disable 1.12.5 power-on reset characteristics table 1.6 power-on reset characteristics parameter symbol condition min typ max unit operating voltage - vss - 5.5 v operating temperature - -40 - +85 reset release level - 1.3 1.4 1.5 v operating current idd - - - 10 ua sidd - - - 1 ua
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 38 1.12.6 brown out detector characteristics table 1.7 brown out detector characteristics parameter symbol condition min typ max unit operating voltage - vss - 5.5 v operating temperature - -40 - +85 detection level - 4.1 4.3 4.4 v - 3.4 3.6 3.7 v - 2.4 2.5 2.6 v - 1.5 1.6 1.7 v hysteresis - - 50 - mv operating current idd - - - 50 ua sidd - - - 1 ua 1.12.7 internal 8mhz, 128khz rc oscillator characteristics table 1.8 internal 8mhz rc oscillator characteristics parameter condition min typ max unit operating voltage 1.62 1.8 3.3 v operating temp. tbd -40 85 clock freq. 25 7.92 8 8.08 mhz operating current average current 140 170 200 ua table 1.9 internal 128khz rc oscillator characteristics condition min typ max unit operating voltage 1.62 1.8 5.5 v operating temp. tbd -40 85 clock freq. tbd - 128 - khz operating current average current 15 20 40 ua  #pcnqi%qorctcvqt%jctcevgtkuvkeu table 1.10 dc electrical characteristics symbol parameter test condition limits unit temp= -40 c to 85 c min typ max il input leakage current vddext=5v, vin=1/2vddext -50 - 50 na
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 39 voffset input offset voltage vddext=5v, vin=1/2vdd 10 - 40 mv iop operating current comp_en=h 1 ma ipd power down current comp_en=l 1 ua table 1.11 ac characteristics symbol parameter test condition limits unit temp=-40 c to 85 c min typ max vrt comparator response time cl= 50pf, vddext=5v - - 500 ns 1.12.9 dc characteristics (vdd =1.8~5.5v, vss =0v, fxin=10.0mhz, ta=-40~+85 ) table 1.12 dc characteristics parameter s y mbol condition min typ max unit input low voltage vil1 resetb (external reset active) p0 -0.5 - 0.2vdd v vil2 - -0.5 - 0.2vdd v input high voltage vih1 resetb (external reset active) p0 0.8vdd - vdd+0.5 v vih2 - 0.7vdd - vdd+0.5 v output low voltage vol1 p0 (iol=10ma, vdd=4.5v) - - 1 v output high voltage voh1 p0 (i oh=-8.57ma, vdd=4.5v) 3.5 - - v input high leakage current iih p0, 1 ua input low leakage current iil p0 -1 ua pull-up resister rpu p0(vdd=5.0v) 20 - 62 k  power supply current idd1 run mode, fxin=8mhz@5v - - 10 ma idd2 sleep mode, fxin=8mhz@5v - - 5 ma idd3 sub active mode, fxin=32.768khz@5v - - 500 ua idd4 stop1 mode,wdt active@5v - - 110 ua idd5 stop2 mode,wdt disable@5v - - 10 ua note) stop1: wdt running stop2: wdt disable
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 40 1.12.10 ac characteristics (vdd=5.0v10%, vss=0v, ta=-40~+85 ) table 1.13 ac characteristics parameter s y mbol pin min typ max unit operating frequency fmcp xin 1 - 8 mhz s y stem clock c y cle time tsys - 125 - 1000 ns oscillation stabilization time (8mh z) tmst1 xin, xout - - 10 ms external clock ?h? or ?l? pulse width tcpw xin 90 - - ns external clock transition time trcp,tfcp xin - - 10 ns interrupt input width tiw int0~int1 2 - - tsys resetb input pulse ?l? width trst resetb 8 - - tsys external counter input ?h? or ?l? pulse width tecw ec0 2 - - tsys event counter transition time trec,tfec ec0 - - 20 ns 1.12.11 typical characteristics these graphs and tables provided in this section are for design guidance only and are not tested or guaranteed. in some graphs or tables the data presented are outside specified operating range (e.g. figure 1.25 ac timing xin 0.9vdd 0.1vdd 1/fmcp tcpw tcpw trcp tfcp ec0 0.8vdd 0.2vdd tiw tiw trst 0.2vdd 0.8vdd 0.2vdd tecw tecw int0 int1 resetb trec tfec
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 41 outside specified vdd range). this is for information only and devices are guaranteed to operate properly only within the specified range. the data presented in this section is a statistical summary of data collected on units from different lots over a period of time. ?typical? represents t he mean of the distribution while ?max? or ?min? represents (mean + 3 ) and (mean - 3 ) respectively where is standard deviation.
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 42 2. functional description 2.1 memory the Z51F0410 mcu addresses two separate address memory stores: program memory and data memory. the logical separation of program and data memory allows data memory to be assessed by 8-bit addresses, which can be more quickly stored and manipulated by 8-bit cpu. nevertheless, 16- bit data memory addresses can also be generated through the dptr register. program memory can only be read, not written to. there can be up to 64k bytes of program memory. in the Z51F0410 flash version of thes e devices the 4k bytes of program memory are provided on-chip. data memory can be read and written to up to 256 bytes internal memory (data) including the stack area. 2.1.1 program memory a 16-bit program counter is capable of addressing up to 64k bytes, but this device has just 4k bytes program memory space. figure 2.1 shows a map of the lower part of the program memory. after reset, the cpu begins execution from location 0000h. each interrupt is assigned a fixed location in program memory. the interrupt causes the cpu to jump to that location, where it commences execution of the service routine. external interrupt 0, for example, is assign ed to location 000bh. if external interrupt 0 is going to be used, its service routine must begin at location 000bh. if the interrupt is not going to be used, its service location is available as general purpose program memory. if an interrupt service routine is short enough (as is often the case in control applications), it can reside entirely within that 8 byte interval. longer service routines can use a jump instruction to skip over subsequent interrupt locations, if other interrupts are in use. - user function mode: 4kbytes included interrupt vector region - nonvolatile and reprogramming memory: flash memory based on eeprom cell 2.1.2 data memory figure 2.2 shows the internal data memory space available. figure 2.1 program memory ffffh 0fffh 0000h 4kbytes
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 43 the internal memory space is divided into three blocks, which are generally referred to as the lower 128, upper 128, and sfr space. internal data memory addresses are always one byte wide, which implies an address space of only 256 bytes. however, the addressing modes for internal ram can in fact accommodate 384 bytes, using a simple trick. direct addresses higher than 7fh access one memory space and indirect addresses higher than 7fh access a different memory space. thus figure 2.2 shows the upper 128 and sfr space occupying the same block of addresses, 80h through ffh, although they are physically separate entities. the lower 128 bytes of ram are present in all 8051 devices as mapped in figure 2.3. the lowest 32 bytes are grouped into 4 banks of 8 registers. program instructions call out these registers as r0 through r7. two bits in the program status word select which register bank is in use. this allows more efficient used of code space, since register instructions are shorter than instructions that use direct addressing. the next 16 bytes above the register banks form a block of bit-addressable memory space. the 8051 instruction set includes a wide selection of single-bit instructions, and the 128 bits in this area can be directly addressed by these instructions. the bit addresses in this area are 00h through 7fh. all of the bytes in the lower 128 can be accessed by either direct or indirect addressing. the upper 128 bytes ram can only be accessed by indirect addressing. these spaces are used for user ram and stack pointer. figure 2.2 data memory map upper 128 bytes internal ram (indirect addressin g) special function registers 128 bytes (direct addressing) lower 128 bytes internal ram (direct or indirect addressing) ffh 80h 7fh 00h ffh 80h
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 44 2.1.3 eeprom data memory the Z51F0410 mcu features 256 bytes eeprom data memory. this area has no relation with ram/flash. it can read and write through sfr with 8-bit unit. for more information about eeprom data memory, see eeprom section figure 2.3 lower 128 bytes ram 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f 60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f 70 71 72 73 74 75 76 77 78 79 7a 7b 7c 7d 7e 7f r5 r4 r3 r2 r1 r0 r6 r7 2fh register bank 0 (8 bytes) register bank 1 (8 bytes) register bank 2 (8 bytes) register bank 3 (8 bytes) bit addressable general purpose register 20h 18h 17h 10h 0fh 08h 07h 00h 30h 7fh 1fh 80 bytes 16 bytes (128bits) 8 bytes 8 bytes 8 bytes 8 bytes
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 45 2.2 sfr map 2.2.1 sfr map summary - reserved m8051 compatible table 2.1 sfr map summary 0h/8h (1) 1h/9h 2h/ah 3h/bh 4h/ch 5h/dh 6h/eh 7h/fh f8h ip1 fuse_ conf2 fuse_ cal2 fuse_ cal1 fuse_ cal0 fuse_ conf1 test_b test_a f0h b - fearl fearm fearh fedr - fuse_ca l3 e8h - accsr femr fecr fesr fetcr ukey0 ukey1 e0h acc - uctrl1 uctrl2 uctrl3 ustat ubaud udata d8h - - i2cmr i2csr i2cscllr i2csclh r i2csdah r i2cdr d0h psw fkey0 fkey1- useed1 useed0 sida sidd i2car c8h - - t4h t4cr t4l c0h p0db p0pc - - - - b8h ip - - - - - - - b0h - - t0cr t0 t1cr t1dr t1 t1pwhr a8h ie ie1 ie2 ie3 eiflag eiedge eipola eienab a0h psr1 p0od eo - - - - - 98h p0io adcm adcrh adcrl wtmr wtr psr0 90h - - pinmcr - - - buzcr tflg 88h p0pd p0pu sccr bccr bitr wdtmr wdtr buzdr 80h p0 sp dpl dph bodr pcon note: 1) these registers are bit-addressable
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 46 2.2.2 sfr map table 2.2 sfr map address function symbol r/w @reset 7 6 5 4 3 2 1 0 80h port 0 data register p0 r/w 0 0 0 0 0 0 0 0 81h stack pointer sp r/w 0 0 0 0 0 1 1 1 82h data pointer register low dpl r/w0000 0 0 00 83h data pointer register high dph r/w 0 0 0 0 0 0 0 0 84h reserved 84h reserved 86h bod control registe r bodr r/w1000 0 0 01 87h power control register pcon r/w 0 0 0 0 0 0 0 0 88h port0 pad data registe r p0pd r - - - - - - - - 89h port 0 pull-up resistor option register p0pu r/w 0 0 0 0 0 0 0 0 8ah system clock control register sccr r/w 0 0 0 0 0 1 0 0 8bh bit clock control register bccr r/w 0 - - - 0 1 0 1 8ch basic interval timer register bitr r/w 0 0 0 0 0 0 0 0 8dh watch dog timer mode register wdtmr r/w 0 0 0 0 0 0 0 0 8eh watch dog timer register wdtr w 1 1 1 1 1 1 1 1 watch dog timer counter register wdtcr r 0 0 0 0 0 0 0 0 8fh buzzer data register buzdr r/w 1 1 1 1 1 1 1 1 90h reserved - - - - - - - - - - 91h reserved - - - - - - - - - - 92h pin mux control register pinmcr r/w - - - 0 0 0 0 0 93h reserved - - - - - - - - - - 94h reserved - - - - - - - - - - 95h reserved - - - - - - - - - - 96h buzzer control register buzcr r/w - - - - - 0 0 0 97h timer 0,1,4 interrupt flag register tflg r/w - 0 0 0 - - - - 98h port 0 direction register p0io r/w 0 0 0 0 0 0 0 0 99h reserved - - - - - - - - - - 9ah a/d converter mode register adcm r/w 1 0 0 0 1 1 1 1 9bh a/d converter result high registe r adcrh r x x x x x x x x 9ch a/d converter result low registe r adcrl r/w 0 1 0 0 - - x x 9dh watch timer mode register wtmr r/w 0 - - 0 0 0 0 0 9eh watch timer registe r wtr w 0111 1 1 11 watch timer counter register wtcr r 0 0 0 0 0 0 0 0
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 47 9fh port selection register0 psr0 r/w 0 0 0 0 0 0 0 0 a0h port selection register1 psr1 r/w0000 0 0 00 a1h port 0 open drain register p0od r/w 0 0 0 0 0 0 0 0 a2h reserved - - ---- - - -- a3h reserved - - - - - - - - - - a4h reserved - - - - - - - - - - a5h reserved - - - - - - - - - - a6h reserved - - - - - - - - - - a7h reserved - - - - - - - - - - a8h interrupt enable register 0 ie r/w 0 0 0 0 0 0 0 0 a9h interrupt enable register 1 ie1 r/w 0 0 0 0 0 0 0 0 aah interrupt enable register 2 ie2 r/w 0 0 0 0 0 0 0 0 abh interrupt enable register 3 ie3 r/w 0 0 0 0 0 0 0 0 ach external interrupt flag register eiflag r/w - - - - 0 0 0 0 adh external interrupt edge register eiedge r/w - - - - 0 0 0 0 aeh external interrupt polarity register eipola w - - - - 0 0 0 0 afh external interrupt enable register eienab r/w - - - - 0 0 0 0 b0h reserved - - - - - - - - - - b1h reserved - - - - - - - - - - b2h timer 0 mode control register t0cr r/w 0 0 0 0 0 0 0 0 b3h timer 0 register t0 r 0 0 0 0 0 0 0 0 timer 0 data register t0dr w 1 1 1 1 1 1 1 1 timer 0 capture data register cdr0 r 0 0 0 0 0 0 0 0 b4h timer 1 mode control register t1cr r/w 0 0 0 0 0 0 0 0 b5h timer 1 data register t1dr w 1 1 1 1 1 1 1 1 timer 1 pwm period register t1ppr w 1 1 1 1 1 1 1 1 b6h timer 1 register t1 r 0 0 0 0 0 0 0 0 timer 1 rwm duty register t1pdr r/w 1 1 1 1 1 1 1 1 timer 1 capture data register cdr1 r 0 0 0 0 0 0 0 0 b7h timer 1 pwm control register t1pwhr r/w 0 0 0 0 0 0 0 0 b8h interrupt priority control register 0 ip r/w 0 0 0 0 0 0 0 0 b9h reserved - - - - - - - - - - bah reserved - - - - - - - - - - bbh reserved - - - - - - - - - - bch reserved - - - - - - - - - - bdh reserved - - - - - - - - - -
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 48 beh reserved - - - - - - - - - - bfh reserved - - ---- - - -- c0h port 0 debounce register p0db r/w 0 0 0 0 0 0 0 0 c1h port 0 pin change interrupt p0pc r/w0000 0 0 00 c2h reserved - - - - - - - - - - c3h reserved - - - - - - - - - - c4h reserved - - - - - - - - - - c5h reserved - - - - - - - - - - c6h reserved - - - - - - - - - c7h reserved - - - - - - - - - c8h reserved - - - - - - - - - - c9h reserved - - - - - - - - - - cah reserved - - - - - - - - - cbh reserved - - - - - - - - - cch reserved - - - - - - - - - cdh timer 4 data high register t4h r 0 0 0 0 0 0 0 0 ceh timer 4 mode control register t4cr r/w 0 0 0 0 0 0 0 0 cfh timer 4 data low register t4l r/w 0 0 0 0 0 0 0 0 d0h program status word register psw r/w 0 0 0 0 0 0 0 0 d1h authetification fab key auth_fkey0 r/w 0 0 0 0 0 0 0 0 d2h authetification fab key auth_fkey1 r/w 0 0 0 0 0 0 0 0 d3h user seed0[7:0] useed0 r/w 0 0 0 0 0 0 0 0 d4h user_seed1[15:8] useed1 r/w 0 0 0 0 0 0 0 0 d5h sid access addresss sida r - - - - - - - - d6h current sid data value sidd r - - - - - - - - d7h i2c slave address register i2car r/w 0 0 0 0 0 0 0 0 d8h reserved - - - - - - - - - - d9h reserved - - - - - - - - - - dah i2c mode control register i2cmr r/w 0 0 0 0 0 0 0 0 dbh i2c status register i2csr r 0 0 0 0 0 0 0 0 dch i2c scl low period register i2cscllr r/w 0 0 1 1 1 1 1 1 ddh i2c scl high period register i2csclhr r/w 0 0 1 1 1 1 1 1 deh i2c sda hold time register i2csdahr r/w 0 0 0 0 0 0 1 1 dfh i2c data register i2cdr r/w 1 1 1 1 1 1 1 1 e0h accumulator register acc r/w 0 0 0 0 0 0 0 0 e1h reserved - - - - - - - - - - e2h usart control register 1 uctrl1 r/w 0 0 0 0 0 0 0 0 e3h usart control register 2 uctrl2 r/w 0 0 0 0 0 0 0 0 e4h usart control register 3 uctrl3 r/w 0 0 0 0 0 0 0 0 e5h usart status register ustat r/w 1 0 0 0 - 0 0 0 e6h usart baud rate generation register ubaud r/w 1 1 1 1 1 1 1 1 e7h usart data register udata r/w 1 1 1 1 1 1 1 1
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 49 e8h reserved - - - - - - - - - - e9h analog comparator control & status register accsr r/w 0 0 0 0 0 0 0 0 eah flash and eeprom mode register femr r/w 0 0 0 0 0 0 0 0 ebh flash and eeprom control registe r fecr r/w 0 0 0 0 0 0 1 1 ech flash and eeprom status registe r fesr r/w 1 0 0 0 0 0 0 0 edh flash and eeprom timer control register fetcr r/w 0 0 0 0 0 0 0 0 eeh authetification key lsb auth_ukey 0 r/w 0 0 0 0 0 0 0 0 efh authetification key msb auth_ukey 1 r/w 0 0 0 0 0 0 0 0 f0h b registe r b r/w 0 0 0 0 0 0 0 0 f1h reserved - - - - - - - - - - f2h flash and eeprom address low register fearl w 0 0 0 0 0 0 0 0 f3h flash and eeprom address middle register fearm w 0 0 0 0 0 0 0 0 f4h flash and eeprom address high register fearh w 0 0 0 0 0 0 0 0 f5h flash and eeprom data registe r fedr r/w 0 0 0 0 0 0 0 0 f6h reserved - - - - - - - - - - f7h vdc trimming for rcosc 128khz fuse_cal3 r/w 0 0 0 0 0 0 0 0 f8h interrupt priority control register 1 ip1 r/w 0 0 0 0 0 0 0 0 f9h configuration option 1 fuse_conf 2 r/w - - - - - - - 0 fah bgr and bod calibration data fuse_cal2 r/w 0 0 0 0 0 0 0 0 fbh intosc calibration data fuse_cal1 r/w 1 0 0 0 0 0 0 0 fch vdc trimming for intosc 8mhz fuse_cal0 r/w 0 0 0 0 0 0 0 0 fdh configuration option 0 fuse_conf 1 r/w - - - 0 0 0 0 0 feh function test register b test_b r/w 0 0 0 0 0 0 0 0 ffh function test register a test_a r/w 0 0 0 0 0 0 0 1 2.2.3 compiler compatible sfr acc (accumulator) : e0h 7 6 5 4 3 2 1 0 acc r/w r/w r/w r/w r/w r/w r/w r/w
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 50 initial value : 00h acc a ccumulator b (b register) : f0h 7 6 5 4 3 2 1 0 b r/w r/w r/w r/w r/w r/w r/w r/w initial value : 00h b b register sp (stack pointer) : 81h 7 6 5 4 3 2 1 0 sp r/w r/w r/w r/w r/w r/w r/w r/w initial value : 07h sp stack pointer dpl (data pointer low byte) : 82h 7 6 5 4 3 2 1 0 dpl r/w r/w r/w r/w r/w r/w r/w r/w initial value : 00h dpl data pointer low byte dph (data pointer high byte) : 83h 7 6 5 4 3 2 1 0 dph r/w r/w r/w r/w r/w r/w r/w r/w initial value : 00h dph data pointer high byte psw (program status word) : d0h 7 6 5 4 3 2 1 0 cy ac f0 rs1 rs0 ov f1 p r/w r/w r/w r/w r/w r/w r/w r/w initial value : 00h cy carry flag ac a uxiliary carry flag f0 general purpose user-definable flag rs1 register bank select bit 1 rs0 register bank select bit 0 ov overflow flag f1 user-definable flag p parity flag. set/cleared by hardware each instruction cycle to indicate an odd/even number of ?1? bits in the accumulator
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 51 2.3 i/o port 2.3.1 i/o ports the Z51F0410 mcu features one i/o ports (p0). each port can be easily configured by software as i/o pin, internal pull up and open drain pin to meet various system configurations and design requirements. also p0 includes function that can generate interrupt according to change of state of the pin. 2.3.2 port register 2.3.2.1 data register (p0) data register is a bidirectional i/o port. if ports are configured as output ports, data can be written to the corresponding bit of the p0. if ports are configured as input ports, the data can be read from the corresponding bit of the p0. 2.3.2.2 direction register (p0io) each i/o pin can independently used as an input or an output through the p0io register. bits cleared in this read/write register will se lect the corresponding pin in p0 to become an input, setting a bit sets the pin to output. all bits are cleared by a system reset. 2.3.2.3 pull-up resistor selection register (p0pu) the on-chip pull-up resistor can be connected to them in 1-bit units with a pull-up resistor selection register (p0pu). the pull-up register selection controls the pull-up resister enable/disable of each port. when the corresponding bit is 1, the pull-up resister of the pin is enabled. when 0, the pull-up resister is disabled. all bits are cleared by a system reset. 2.3.2.4 open-drain selection register (p0od) there is internally open-drain selection register (p0od) in p0. the open-drain selection register controls the open-drain enable/disable of each port. ports become push-pull by a system reset. you should connect an external resistor in open-drain output mode. 2.3.2.5 debounce enable register (p0db) p0 support debounce function. debounce time of each ports has 1us, but if p0[2] uses external reset function, it has 3us debounce time. (except p0[2], other port initialization state is off) 2.3.2.6 pin change interrupt enable register (p0pc) the p0 can support pin change interrupt function. pin change interrupts pci will trigger if any
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 52 enabled p0[7:0] pin toggles. the p0pc register control which pins contribute to the pin change interrupts. 2.3.2.7 pin mux control register (pinmcr) in the 10pin pkg, the secondary pin muxing function is added for pin efficiency. 2.3.2.8 pin pad data register (p0pd) it is used to read directly pad data regardless of port direction. 2.3.2.9 port selection register0(psr0, psr1) adc channel selection (psr0), and comparator output selection (psr1) disables the logic input gate to prevent the leakage current. 2.3.2.10 register map table 2.3 register map name address dir default description p0 80h r/w 00h p0 data register p0io 98h r/w 00h p0 direction register p0pu 89h r/w 00h p0 pull-up resistor selection register p0od a 1h r/w 00h p0 open-drain selection register p0db c0h r/w 00h p0 debounce enable register p0pc c1h r/w 00h p0 pin change interrupt enable register p0pd 88h r/w 00h p0 pad data register pinmcr 92h r/w 00h pin mux control register 2.3.3 p0 port 2.3.3.1 p0 port description p0 is 8-bit i/o port. p0 control registers consist of data register (p0), direction register (p0io), debounce enable register (p0db, p2db), pull-up register selection register (p0pu), open-drain selection register (p0od). 2.3.3.2 register description for p0 p0 (p0 data register) : 80h 7 6 5 4 3 2 1 0 p07 p06 p05 p04 p03 p02 p01 p00 r/w r/w r/w r/w r/w r/w r/w r/w
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 53 initial value : 00h p0[7:0] i/o data p0io (p0 direction register) : 98h 7 6 5 4 3 2 1 0 p07io p06io p05io p04io p03io p02io p01io p00io r/w r/w r/w r/w r/w r/w r/w r/w initial value : 00h p0io[7:0] p0 data i/o direction. 0 input 1 output p0pu (p0 pull-up resistor selection register) : 89h 7 6 5 4 3 2 1 0 p07pu p06pu p05pu p04pu p03pu p02pu p01pu p00pu r/w r/w r/w r/w r/w r/w r/w r/w initial value : 00h p0pu[7:0] configure pull-up resistor of p0 port 0 disable 1 enable p0od (p0 open-drain selection register) : a1h 7 6 5 4 3 2 1 0 p07od p06od p05od p04od p03od p02od p01od p00od r/w r/w r/w r/w r/w r/w r/w r/w initial value : 00h p0od[7:0] configure open-drain of p0 port 0 disable 1 enable p0db (p0 debounce enable register) : c0h 7 6 5 4 3 2 1 0 p07db p06db p05db p04db p03db p02db p01db p00db r/w r/w r/w r/w r/w r/w r/w r/w initial value : 00h p0db[7:0] configure debounce of p0 port 0 disable 1 enable p0pc (p0 pin change interrupt enable register) : c1h 7 6 5 4 3 2 1 0 p07pc p06pc p05pc p04pc p03pc p02pc p01pc p00pc r/w r/w r/w r/w r/w r/w r/w r/w initial value : 00h
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 54 p0pc[7:0] configure pin change interrupt of p0 port 0 disable 1 enable psr0 (adc pin selection register) : 9fh 7 6 5 4 3 2 1 0 ain07_en ain06_en ain05_en ain04_en ain03_en ain02_en ain01_en ain00_en r/w r/w r/w r/w r/w r/w r/w r/w initial value : 00h psr0[7:0] a dc channel selection (disable logic input gate) 0 disable 1 enable psr1 (comparator pin selection register) : a0h 7 6 5 4 3 2 1 0 aco_en r/w initial value : 00h psr1[0] a nalog comparator output enable (disable logic input gate) 0 disable 1 enable p0pd (p0 pad data register) : 88h 7 6 5 4 3 2 1 0 p0pd7 p0pd 6 p0pd 5 p0pd 4 p0pd 3 p0pd 2 p0pd 1 p0pd 0 r/w r/w r/w r/w r/w r/w r/w r/w initial value : 00h p0pd[7:0] pad input data pinmcr ( pin mux control register) : 92h 7 6 5 4 3 2 1 0 - - - tmr_cfg buz_cfg i2c_cfg usart_cf g xint_cfg - - - r/w r/w r/w r/w r/w initial value : 00h tr_cfg timer pin control mode buz_cfg buzzer pin control mode i2c_cfg i2c pin control mode usart_cfg usart pin control mode xint_cfg external interrupt pin control mode
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 55 figure 2.4 debounce function external port pin signal dbclk port data min. 5 clock counting
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 56 3. interrupt controller 3.1 overview the Z51F0410 mcu supports up to 15 interrupt sources. the interrupts have separate enable register bits associated with them, allowing software control. they can also have four levels of priority assigned to them. the nonmaskable interrupt source is always enabled with a higher priority than any other interrupt source, and is not controllable by software. the interrupt controller has following features: - receive the request from 24 interrupt source - 6 group priority - 4 priority levels - multi interrupt possibility - if the requests of different priority levels are received simultaneously, the request of higher priority level is serviced - each interrupt source can control by ea bit and each iex bit - interrupt latency: 5?8 machine cycles in single interrupt system the nonmaskable interrupt is always enabled. the maskable interrupts are enabled through four pair of interrupt enable registers (ie, ie1, ie2, ie3). bits of ie, ie1, ie2, ie3 register each individually enable/disable a particular interrupt source. overall control is provided by bit 7 of ie (ea). when ea is set to ?0?, all interrupts are disabled: when ea is set to ?1?, interrupts are individually enabled or disabled through the other bits of the interrupt enable registers. the Z51F0410 mcu supports a four- level priority scheme. each maskable interrupt is individually assigned to one of four priority levels by writing to ip or ip1. external interrupt default mode is level-trigger basically but if needed, it is able to change edge- trigger mode. table 3.1 shows the interrupt group priority level that is available for sharing interrupt priority. priority sets two bit which is to ip and ip1 register about group. interrupt service routine services higher priority. if two requests of different priority levels are received simultaneously, the request of higher priority level is serviced. if the request of same or lower priority level is received, that request is not serviced. table 3.1 interrupt group priority level interrupt group highest lowest 0 (bit0) interrupt0 interrupt6 interrupt12 interrupt18 highest 1 (bit0) interrupt1 interrupt7 interrupt13 interrupt19 2 (bit0) interrupt2 interrupt8 interrupt14 interrupt20 3 (bit0) interrupt3 interrupt9 interrupt15 interrupt21 4 (bit0) interrupt4 interrupt10 interrupt16 interrupt22 5 (bit0) interrupt5 interrupt11 interrupt17 interrupt23 lowest 3.2 external interrupt the external interrupt on int0, int1 pins receive various interrupt request depending on the edge selection register eiedge (external interrupt edge register) and eipola (external interrupt polarity register) as shown in figure 3.1. also each external interrupt source has control setting bits. the
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 57 eiflag (external interrupt flag register) register provides the status of external interrupts. figure 3.1 external interrupt description int1 pi flag1 int2 it t int0 pi flag0 int1 it t eiedge, eipola [ad h ]external interrupt edge register [ae h ]external interrupt polarity 2 2
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 58 3.3 block diagram figure 3.2 block diagram of interrupt tend t0if t1if int15 int16 t4if aflag cmpif wtifr wdtmr bccr romi f ieds0 ie [a8 h ] int0 int1 reser d reser d 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 ie1 [a9 h ] ie2 [aa h ] ie3 [ab h ] ip [b8 h ] ip1 [f8 h ] eiflag.0[ac h ] release stop/sleep flag0 flag1 flag2 flag3 pci txc rxc int11 int6 int7 int8 ea (ie.7[a8 h ]) pci reserved uart rx uart tx reserved 2 - wi re interface timer 0 timer 1 reserved reserved timer4 adc comparator wt wdt bit eeprom eiflag.1[ac h ] - - i2csr.6 [db h ] - ustat.5 [e5 h ] ustat.6 [e5 h ] t1isr[7:2] [c4 h ] adcm.4[9a h ] wtmr.4[9d h ] wtmr.0[8d h ] bitf.7[8b h ] priority high priority low
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 59 3.4 interrupt vector table the interrupt controller supports 24 interrupt sources as shown in the table 3.2 below. when interrupt becomes service, long call instruction (lcall) is executed in the vector address. interrupt request 24 has a decided priority order. table 3.2 interrupt vector address table interrupt source symbol interrupt enable bit polarity mask vector address hardware reset resetb 0 0 nonmaskable 0000h - int0 ie0.0 1 maskable 0003h external interrupt 0 int1 ie0.1 2 maskable 000bh external interrupt 1 int2 ie0.2 3 maskable 0013h - int3 ie0.3 4 maskable 001bh - int4 ie0.4 5 maskable 0023h pin change interrupt (p0) int5 ie0.5 6 maskable 002bh - int6 ie1.0 7 maskable 0033h - int7 ie1.1 8 maskable 003bh - int8 ie1.2 9 maskable 0043h uart rx int9 ie1.3 10 maskable 004bh uart tx int10 ie1.4 11 maskable 0053h - int11 ie1.5 12 maskable 005bh i2c int12 ie2.0 13 maskable 0063h t0 int13 ie2.1 14 maskable 006bh t1 int14 ie2.2 15 maskable 0073h - int15 ie2.3 16 maskable 007bh - int16 ie2.4 17 maskable 0083h t4 int17 ie2.5 18 maskable 008bh adc int18 ie3.0 19 maskable 0093h analog comparator int19 ie3.1 20 maskable 009bh wt int20 ie3.2 21 maskable 00a3h wdt int21 ie3.3 22 maskable 00abh bit int22 ie3.4 23 maskable 00b3h eeprom int23 ie3.5 24 maskable 00bbh for maskable interrupt execution, first ea bit must se t ?1? and specific interrupt source must set ?1? by writing a ?1? to associated bit in the iex. if interrupt request is received, specific interrupt request flag set ?1?. and it remains ?1? until cpu accepts interrupt. after that, interrupt request flag will be cleared automatically. 3.5 interrupt sequence an interrupt request is held until the interrupt is accepted or the interrupt latch is cleared to ?0? by a reset or an instruction. interrupt acceptance always generates at last cycle of the instruction. so instead of fetching the current instruction, cpu executes internally lcall instruction and saves the pc stack. for the interrupt service routine, the interrupt controller gives the address of ljmp instruction to cpu. after finishing the current instruct ion, at the next instruction to go interrupt service routine needs 3?9 machine cycle and the interrupt service task is terminated upon execution of an interrupt return instruction [reti]. after generating interrupt, to go to interrupt service routine, the following process is progressed
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 60 figure 3.3 interrupt vector address table saves pc value in order to continue process again after executing isr ie.ea flag ? 1 iex.y ? 1 1 program counter low byte sp ? sp + 1 m(sp) ? (pcl) 2 program counter high byte sp ? sp + 1 m(sp) ? (pch) 3 interrupt vector address occurrence (interrupt vector address) 4 isr(interrupt service routine) move, execute 5 return from isr reti 6 program counter high byte recovery (pcl) ? (sp-1) 7 main program execution 9 program counter low byte recovery (pcl) ? (sp-1) 8
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 61 3.6 effective timing after controlling interrupt bit case a) control interrupt enable register (ie, ie1, ie2, ie3) case b) interrupt flag register 3.7 multi interrupt if two requests of different priority levels are received simultaneously, the request of higher priority level is serviced. if requests of the interrupt are received at the same time simultaneously, an interrupt polling sequence determines by hardware which reques t is serviced. however, multiple processing through software for special features is possible. figure 3.5 effective timing of interrupt flag register interrupt flag register command next instruction next instruction after executing next instruction, interrupt flag result is effective. figure 3.4 effective timing of interrupt enable register interrupt enable register command next instruction next instruction after executing ie set/clear, enable register is effective.
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 62 following example is shown to service int0 routine during int1 routine in figure 3.6. in this example, int0 interrupt priority is higher than int1 interrupt priority. if some interrupt is lower than int1 priority, it can?t service its interrupt routine. example) software multi interrupt: int1: mov ie, #81h ; enable int0 only mov ie1, #00h ; disable other : mov ie, #0ffh ; enable all interrupts mov ie1, #0ffh reti main program service occur int1 interrupt int1 isr enable int0 disable others ea occur int0 interrupt int0 isr reti reti enable int0 enable others figure 3.6 execution of multi interrupt
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 63 3.8 interrupt enable accept timing 3.9 interrupt service routine address 3.10 saving/restore general-purpose registers figure 3.9 saving/restore process diagram & sample source main task saving register restoring register interrupt service task intxx : push psw push dpl push dph push b push acc interrupt_processing: ? ? pop acc pop b pop dph pop dpl pop psw reti figure 3.8 correspondence between vector ta ble address and the entry address of isp 01h 25h 00b3h 00b4h basic interval timer vector table address 0eh 2eh 0125h 0126h basic interval timer service routine address figure 3.7 interrupt response timing diagram interrupt latched interrupt goes active system clock max. 4 machine cycle 4 machine cycle interrupt processing : lcall & ljmp interrupt routine
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 64 3.11 interrupt timing interrupt source sampled at last cycle of the command. when sampling interrupt source, it is decided to low 8-bit of interrupt vector. m8051w core makes interrupt acknowledge at first cycle of command, executes long call to jump interrupt routine as int_vec. note) command cycle c?p?: l=last cycle, 1=1 st cycle or 1 st phase, 2=2 nd cycle or 2 nd phase 3.12 interrupt register overview 3.12.1 interrupt enable register (ie, ie1, ie2, ie3) interrupt enable register consists of global interrupt control bit (ea) and peripheral interrupt control bits. totally 24 peripheral are able to control interrupt. 3.12.2 interrupt priority register (ip, ip1) the 24 interrupt divides 6 groups which have each 4 interrupt sources. a group can decide 4 levels interrupt priority using interrupt priority register. level 3 is the high priority, while level 0 is the low priority. initially, ip, ip1 reset value is ?0?. at that initialization, low interrupt number has a higher priority than high interrupt number. if decided th e priority, low interrupt number has a higher priority than high interrupt number in that group. clp2 clp1 c2p1 c1p1 c2p2 c1p2 clp2 interrupt sampled here 8-bit interrupt vector int_src intr_ack last_cyc intr_lcall int_vec proga sclk {8?h00, int_vec} figure 3.10 timing chart of interrupt accep tance and interrupt return instruction
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 65 3.12.3 external interrupt flag register (eiflag) the external interrupt flag register is set to ?1? when the external interrupt generating condition is satisfied. the flag is cleared when the interrupt r outine is executed. alternatively, the flag can be cleared by writing a ?0? to it. 3.12.4 external interrupt edge register (eiedge) the external interrupt edge register determines which type of edge or level sensitive interrupt. initially, default value is level. for level, write ?0? to related bit. for edge, write ?1? to related bit. 3.12.5 external interrupt polarity register (eipola) according to eiedge register, the external interrupt polarity (eipola) register has a different meaning. if eiedge is level type, eipola is able to have low/high level value. if eiegde is edge type, eipola is able to have rising/falling edge value. 3.12.6 external interrupt enable register (eienab) when the external interrupt enable register is written to ?1?, the corresponding external pin interrupt is enabled. the eiedge and eipola register defines whether the external interrupt is activated on rising or falling edge or level sensed. 3.12.7 register map table 3.3 register map name address dir default description ie a 8h r/w 00h interrupt enable register ie1 a 9h r/w 00h interrupt enable register 1 ie2 a ah r/w 00h interrupt enable register 2 ie3 a bh r/w 00h interrupt enable register 3 ip b8h r/w 00h interrupt polarity register ip1 f8h r/w 00h interrupt polarity register 1 eiflag a ch r/w 00h external inte rrupt flag register eiedge a dh r/w 00h external inte rrupt edge register eipola a eh r/w 00h external interrupt polarity register eienab a fh r/w 00h external interrupt enable register 3.13 interrupt register description the interrupt register is used for controlling interrupt functions. also it has external interrupt control registers. the interrupt register consists of interrupt enable register (ie), interrupt enable register 1 (ie1), interrupt enable register 2 (ie2) and interrupt enable register 3 (ie3). for external interrupt, it consists of external interrupt flag register (eiflag), external interrupt edge register (eiedge), external interrupt polarity register (eipola) an d external interrupt enable register (eienab). 3.13.1 register description for interrupt ie (interrupt enable register) : a8h 7 6 5 4 3 2 1 0
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 66 ea - int5e - - int2e int1e - r/w r r/w- r/ r r/w r/w r/ initial value : 00h ea enable or disable all interrupt bits 0 a ll interrupt disable 1 a ll interrupt enable int5e enable or disable pin change interrupt 0 disable 1 enable int2e enable or disable external interrupt 1 0 disable 1 enable int1e enable or disable external interrupt 0 0 disable 1 enable ie1 (interrupt enable register 1) : a9h 7 6 5 4 3 2 1 0 - - - int10e- int9e - - - r r r/ - r/w r/w r r r initial value : 00h int10e enable or disable uart tx interrupt 0 disable 1 enable int9e enable or disable uart rx interrupt 0 disable 1 enable ie2 (interrupt enable register 2) : aah 7 6 5 4 3 2 1 0 - - int17e - - int14e int13e int12e r r r/w- r r r/w r/w r/w initial value : 00h int17e enable or disable timer 4 interrupt 0 disable 1 enable 1 enable int14e enable or disable timer 1 interrupt 0 disable 1 enable int13e enable or disable timer 0 interrupt 0 disable 1 enable int12e enable or disable i2c interrupt 0 disable 1 enable
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 67 ie3 (interrupt enable register 3) : abh 7 6 5 4 3 2 1 0 - - int23e int22e- int21e int20e int19e int18e r r r/w- r/w r/w r/w r/w r/w initial value : 00h int23e enable or disable eeprom interrupt 0 disable 1 enable int22e enable or disable bit interrupt 0 disable 1 enable int21e enable or disable wdt interrupt 0 disable 1 enable int20e enable or disable wt interrupt 0 disable 1 enable int19e enable or disable analog comparator interrupt 0 disable 1 enable int18e enable or disable adc interrupt 0 disable 1 enable ip (interrupt priority register) : b8h 7 6 5 4 3 2 1 0 - - ip5 ip4 ip3 ip2 ip1 ip0 r r r/w- r/w r/w r/w r/w r/w initial value : 00h ip1 (interrupt priority register 1) : f8h 7 6 5 4 3 2 1 0 - - ip15 ip14 ip13 ip12 ip11 ip10 r r r/w- r/w r/w r/w r/w r/w initial value : 00h ip[5:0], ip1[5:0] select interrupt group priority ip1x ipx description 0 0 level 0 (lowest) 0 1 level 1 1 0 level 2 1 1 level 3 (highest) eiflag (external interrupt flag register) : ach 7 6 5 4 3 2 1 0 - - - - - - flag1 flag0 r r r- r r r r/w r/w
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 68 initial value : 00h flag[1:0] if external interrupt is occurred, the flag becomes ?1?. the flag can be cleared by writing a ?0? to bit 0 external interrupt not occurred 1 external interrupt occurred eiedge (external interrupt edge register) : adh 7 6 5 4 3 2 1 0 - - - - - - edge1 edge0 r/w- r/w- r/w- r/w r/w r/w r/w r/w initial value : 00h edge[1:0] determines which type of edge or level sensitive interrupt may occ ur. 0 level (default) 1 edge eipola (external interrupt polarity register) : aeh 7 6 5 4 3 2 1 0 - - - - - - pola1 pola0 r/w r/w r/w- r/w r/w r/w r/w r/w initial value : 00h pola[1:0] a ccording to eiedge, external interrupt polarity register has a different means. if eiedge is level type, external interrupt polarity is able to have low/high level value. if eiegde is edge type, external interrupt polarity is able to have rising/ falling edge value. level case: 0 when high level, interrupt occurred (default) 1 when low level, interrupt occurred edge case: 0 when rising edge, interrupt occurred (default) 1 when falling edge, interrupt occurred eienab (external interrupt enable register) : afh 7 6 5 4 3 2 1 0 - - - - - - enab1 enab0 r/w- r/w- r/w- r/w r/w r/w r/w r/w initial value : 00h enab[1:0] control external interrupt 0 disable (default) 1 enable
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 69 4. peripheral hardware 4.1 clock generator 4.1.1 overview as shown in figure 4.1, the clock generator produces the basic clock pulses which provide the system clock to be supplied to the cpu and the peripheral hardware. it contains main-frequency clock oscillator. the system clock operation can be easily obtained by attaching a crystal between the xin and xout pin, respectively. the system clock can al so be obtained from the external oscillator. in this case, it is necessary to put the external clock signal into the xin pin and open the xout pin. the default system clock is int-rc oscillator and the de fault division rate is one. in order to stabilize system internally, use 128 khz ring-osc illator (50%) for bit and wdt. - calibrated internal rc oscillator (8 mhz / 1%) . int-rc osc/1 (default system clock) . int-rc osc/2 (4 mhz) . int-rc osc/4 (2 mhz) . int-rc osc/8 (1 mhz) - crystal oscillator (1~8 mhz) - sub-clock crystal oscillator (32.768 khz) - internal ring-oscillator (128 khz / 50%) 4.1.2 block diagram main osc system clockgen. wdt bit x in x out pdown dclk system clock masking control bit overflow sclk (core, system, peripherals) sub osc sub xin sub xout clock change divider wt int-rc osc (8mhz) ring-osc (128khz) wons pdown f xin f sub f intrc 1/2 1/4 1/8 1/1 f ringrc figure 4.1 clock generator block diagram
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 70 4.1.3 register map table 4.1 sscr register map name address dir default description sccr 8ah r/w 04h system and clock control register 4.1.4 clock generator register description the clock generation register uses clock cont rol for system operation. the clock generation consists of system and clock register. 4.1.5 register description for clock generator sccr (system and clock control register) : 8ah 7 6 5 4 3 2 1 0 wons div1 div0 cbys istop xstop cs1 cs0 r/w r/w r/w- r/w r/w r/w r/w r/w initial value : 04h wons control the operation of wdt rc-oscillation during stop mode 0 wdtrc-oscillator is disabled at stop mode (=stop2) 1 wdtrc-oscillator is enabled at stop mode (=stop1) div[1:0] when using fintrc as system clock, determine division rate. note) when using fintrc as system clock, only division rate come into effect. note) to change by software, cbys set to ?1? div1 div0 description 0 0 fintrc/1 (8mhz) 0 1 fintrc/2 (4mhz) 1 0 fintrc/4 (2mhz) 1 1 fintrc/8 (1mhz) cbys control the scheme of clock change. if this bit set to ?0?, clock change is controlled by hardware. but if this set to ?1?, clock change is controlled by software. ex) when setting cs[1:0], if cbys bit set to ?0?, it is not changed right now, cpu goes to stop mode and then when wake-up, it applies to clock change. note) when clear this bit, keep other bits in sccr 0 clock changed by hardware during stop mode (default) 1 clock changed by software. after clock is changed, it should be cleared for low power. istop control the operation of int-rc oscillation note) when cbys=?1?, it is applied 0 rc-oscillation enable (default) 1 rc-oscillation disable xstop control the operation of x-tal oscillation note1) when cbys=?1?, it is applied note2) if xinena bit in fuse_conf to ?0?, xstop is fixed to ?1? 0 x-tal oscillation enable 1 x-tal oscillation disable (default) cs[1:0] determine system clock note) by cbys bit, reflection point is decided cs1 cs0 description
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 71 0 0 fintrc intrc (8 mhz) 0 1 fxin external main clock (1~8 mhz) 1 0 fsub (32.768 khz) 1 1 fringrc (128khz, 50%)
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 72 4.2 bit 4.2.1 overview the Z51F0410 mcu features one 8-bit basic interval timer that is free-run and can?t stop. block diagram is shown in figure 4.2. in addition, the basic interval timer generates the time base for watchdog timer counting. it also provides a basic interval timer interrupt (bitf). the Z51F0410 mcu has these basic interval timer (bit) features: - during power on, bit gives a stable clock generation time - on exiting stop mode, bit gives a stable clock generation time - as clock function, time interrupt occurrence 4.2.2 block diagram 4.2.3 register map table 4.2 bit register map name address dir default description bccr 8bh r/w 05h bit clock control register bitr 8ch r 00h basic interval timer register figure 4.2 bit block diagram div internal ring- osc (128khz/ 50%) bitr (8-bit counter) & bitr[7:0] & bitr[6:0] & bitr[5:0] & bitr[4:0] & bitr[3:0] & bitr[2:0] & bitr[1:0] & bitr[0] bitr[7] bitr[6] bitr[5] bitr[4] bitr[3] bitr[2] bitr[1] bitr[0] bck[2:0] bit interrupt bit_out (wdt clock source)
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 73 4.2.4 bit interval timer register description the bit interval timer register consists of bit clock control register (bccr) and basic interval timer register (bitr). if bclr bit set to ?1?, bitr becomes ?0? and then counts up. after 1 machine cycle, bclr bit is cleared as ?0? automatically. 4.2.5 register description for bit interval timer bccr (bit clock control register) : 8bh 7 6 5 4 3 2 1 0 bitf - - - bclr bck2 bck1 bck0 r/w r r r r/w r/w r/w r/w initial value : 05h bitf when bit interrupt occurs, this bit becomes ?1?. for clearing bit, write ?0? to this bit. 0 no generation 1 generation bclr if bclk bit is written to ?1?, bit counter is cleared as ?0? 0 free running 1 clear counter bck[2:0] select bit overflow period (bit clock=4 khz) bck2 bck1 bck0 0 0 0 0.5msec (bit clock * 2) 0 0 1 1msec 0 1 0 2msec 0 1 1 4msec 1 0 0 8msec 1 0 1 16msec (default) 1 1 0 32msec 1 1 1 64msec bitr (basic interval timer register) : 8ch 7 6 5 4 3 2 1 0 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 r r r r r r r r initial value : 00h bit[7:0] bit counter
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 74 4.3 wdt 4.3.1 overview the watchdog timer rapidly detects the cpu malfunction such as endless looping caused by noise or the like, and resumes the cpu to the normal state. the watchdog timer signal for detecting malfunction can be selected either a reset cpu or an interrupt request. when the watchdog timer is not being used for malfunction detection, it can be used as a timer to generate an interrupt at fixed intervals. it is possible to use free running 8-bit timer mode (wdtrson=?0?) or watch dog timer mode (wdtrson=?1?) as setting wdtmr[6] bit. if writing wdtmr[5] to ?1?, wdt counter value is cleared and counts up. after 1 machine cycle, this bit has ?0? automatically. the watchdog timer consists of 8- bit binary counter and the watchdog timer data register. when the value of 8-bit binary counter is equal to the 8 bits of wdtr, the interrupt request flag is generated. this can be used as watchdog timer interrupt or reset the cpu in accordance with the bit wdtrson. the clock source of watch dog timer is bit overflow output. the interval of watchdog timer interrupt is decided by bit overflow period and wdtr set value. the equation is as below wdt interrupt interval = (bit inte rrupt interval) x (wdtr value+1) 4.3.2 block diagram 4.3.3 register map table 4.3 wdt register map name address dir default description w dtr 8eh w ffh w atch dog timer register w dtcr 8eh r 00h w atch dog timer counter register w dtmr 8dh r/w 00h w atch dog timer mode register figure 4.3 wdt block diagram to reset circuit [8e h ] clear wdten bit overflow wdtcr wdtr watchdog timer register [8e h ] watchdog timer counter register wdtifr wdtmr wdtcl wdtrson int_ack clear wdtif 1/2, 1/4, 1/8 wckdiv[1:0]
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 75 4.3.4 watch dog timer register description the watch dog timer (wdt) register consists of watch dog timer register (wdtr), watch dog timer counter register (wdtcr) and watch dog timer mode register (wdtmr). 4.3.5 register description for watch dog timer wdtr (watch dog timer register:write case) : 8eh 7 6 5 4 3 2 1 0 wdtr7 wdtr 6 wdtr 5 wdtr 4 wdtr 3 wdtr 2 wdtr 1 wdtr 0 w w w w w w w w initial value : ffh wdtr[7:0] set a period wdt interrupt interval=(bit interrupt interval) x(wdtr value+1) note) to guarantee proper operation, the data should be greater than 01h. wdtcr (watch dog timer counter register:read case) : 8eh 7 6 5 4 3 2 1 0 wdtcr 7 wdtcr 6 wdtcr 5 wdtcr 4 wdtcr 3 wdtcr 2 wdtcr 1 wdtcr 0 r r r r r r r r initial value : 00h wdtcr[7:0] wdt counter wdtmr (watch dog timer mode register) : 8dh 7 6 5 4 3 2 1 0 wdten wdtrson wdtcl wckdiv1 wckdiv0 - - wdtifr r/w r/w r/w r/w r/w - - r/w initial value : 00h wdten control wdt operation 0 disable 1 enable wdtrson control wdt reset operation 0 free running 8-bit timer 1 watch dog timer reset on wdtcl clear wdt counter 0 free run 1 clear wdt counter (auto clear after 1 cycle) wckdiv[1:0] wdt clock division selection 00 default no divided 01 wdt clock = bit clock / 2 10 wdt clock = bit clock / 4 11 wdt clock = bit clock / 8 wdtifr when wdt interrupt occurs, this bit becomes ?1?. for clearing bit, write ?0? to this bit or auto clear by int_ack signal. 0 wdt interrupt no generation 1 wdt interrupt generation
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 76 4.3.6 wdt interrupt timing waveform source clock bit overflow wdtcr[7:0] wdtr[7:0] wdtif interrupt wdtresetb wdtcl occur wdtr ? 0000_0011b match detect counter clear reset 0 1 2 3 0 1 2 3 0 1 2 n 3 figure 4.4 wdt interrupt timing waveform
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 77 4.4 wt 4.4.1 overview the watch timer has the function for rtc (real time clock) operation. it is generally used for rtc design. the internal structure of the watch timer consists of the clock source select circuit, timer counter circuit, output select circuit and watch timer mode register. to operate the watch timer, determine the input clock source, output interval and set wten to ?1? in watch timer mode register (wtmr). it is able to execute simultaneously or indi vidually. to stop or reset wt, clear the wten bit in wtmr register. even if cpu is stop mode, sub clock is able to be alive so wt can continue the operation. the watch timer counter circuits may be composed of 21-bit counter which is low 14-bit with binary counter and high 7-bit with auto reload counter in order to raise resolution. in wtr, it can control wt clear and set interval value at write ti me, and it can read 7-bit wt counter value at read time. 4.4.2 block diagram 4.4.3 register map table 4.4 wt register map name address dir default description w tmr 9dh r/w 00h w atch timer mode register w tr 9eh w 7fh w atch timer register w tcr 9eh r 00h w atch timer counter register 4.4.4 watch timer register description the watch timer register (wt) consists of watch timer mode register (wtmr), watch timer counter register (wtcr) and watch timer register (wtr). as wtmr is 6-bit writable/readable figure 4.5 watch timer block diagram 128 fx p r e s c a l e r mux wtr 64 14bit binary counter wtr write 256 f sub (32.768khz) f wck / 2 14 timer counter (7bit auto reload counter) mux wtifr wten - - wtifr wtin1 wtin0 wtck1 wtck0 wtcl wtr6 wtr5 wtr4 wtr2 wtr2 wtr1 wtr0 - wtcr6 wtcr5 wtcr4 wtcr2 wtcr2 wtcr1 wtcr0 wtcr wtr read wtmr 7 f wck f wck /2 14 f wck /2 13 f wck /2 12 2 f wck / 2 14 x (7bit wtr value +1) wtif clear int_ack
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 78 register, wtmr can control the clock source (wtck), interrupt interval (wtin) and function enable/disable (wten). also there is wt interrupt flag bit (wtifr). 4.4.5 register description for watch timer wtmr (watch timer mode register) : 9dh 7 6 5 4 3 2 1 0 wten - - wtifr wtin1 wtin0 wtck1 wtck0 r/w - - r/w r/w r/w r/w r/w initial value :0 0h wten control watch timer 0 disable 1 enable wtifr when wt interrupt occurs, this bit becomes ?1?. for clearing bit, write ?0? to this bit or auto clear by int_ack signal. 0 wt interrupt no generation 1 wt interrupt generation wtin[1:0] determine interru pt interval wtin1 wtin0 description 0 0 fwck/2^11 0 1 fwck/2^13 1 0 fwck/2^14 1 1 fwck/2^14 x (7bit wt value) wtck[1:0] determine source clock wtck1 wtck0 description 0 0 fsub 0 1 fx/256 1 0 fx/128 1 1 fx/64 remark: fx? main system clock oscillation frequency fsub- sub clock oscillation frequency fwck- selected watch timer clock wtr (watch timer register:write case) : 9eh 7 6 5 4 3 2 1 0 wtcl wtr 6 wtr 5 wtr 4 wtr 3 wtr 2 wtr 1 wtr 0 w w w w w w w w initial value : 7fh wtcl clear wt counter 0 free run 1 clear wt counter (auto clear after 1 cycle) wtr[6:0] set wt period wt interrupt interval=(fwck/2^14) x(7bit wt value+1) note) to guarantee proper operation, it is greater than 01h to write wtr. wtcr (watch timer counter register:read case) : 9eh 7 6 5 4 3 2 1 0 wtcr 6 wtcr 5 wtcr 4 wtcr 3 wtcr 2 wtcr 1 wtcr 0
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 79 - r r r r r r r initial value : 00h wtcr[6:0] wt counter
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 80 4.5 timer/pwm 4.5.1 8-bit timer/event counter 0, 1 4.5.1.1 overview timer 0 and timer 1 can be used either two 8-bit timer/counter or one 16-bit timer/counter with combine them. each 8-bit timer/event counter module has multiplexer, 8-bit timer data register, 8-bit counter register, mode register, input capture register, comparator. for pwm, it has pwm register (t1ppr, t1pdr, t1pwhr). it has seven operating modes: - 8 bit timer/counter mode - 8 bit capture mode - 8 bit compare output mode - 16 bit timer/counter mode - 16 bit capture mode - 16 bit compare output mode - pwm mode the timer/counter can be clocked by an internal or external clock source (external ec0). the clock source is selected by clock select logic which is controlled by the clock select (t0ck[2:0], t1ck[1:0]). - timer0 clock source : fx/2, 4, 16, 64, 256, 1024, 4096, ec0 - timer1 clock source : fx/1, 2, 16, t0ck in the capture mode, by int0, int1, the data is captured into input capture register. the timer 0 outputs the compare result to t0 port in 8/16-bit mode. also the timer 1 outputs the result t1 port in the timer mode and the pwm wave form to pwm1 in the pwm mode. table 4.5 operating modes of timer 16 bit cap0 cap1 pwm1e t0ck[2:0] t1ck[1:0] t0/1_pe timer 0 timer 1 0 0 0 0 xxx xx 00 8 bit timer 8 bit timer 0 0 1 0 111 xx 00 8 bit event counter 8 bit capture 0 1 0 0 xxx xx 01 8 bit capture 8 bit compare output 0 0 0 1 xxx xx 11 8 bit timer/counter 10 bit pwm 1 0 0 0 xxx 11 00 16 bit timer 1 0 0 0 111 11 00 16 bit event counter 1 1 1 0 xxx 11 00 16 bit capture 1 0 0 0 xxx 11 01 16 bit compare output
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 81 4.5.1.2 8-bit timer/counter mode the 8-bit timer/counter mode is selected by control registers as shown in figure 4.6. the two 8-bit timers have each counter and data register. the counter register is increased by internal or external clock input. the timer 0 can use the input clock with 2, 4, 16, 64, 256, 1024, 4096 prescaler division rates (t0ck[2:0]). the timer 1 can use the input clock with 1, 2, 16 and timer 0 overflow clock (t1ck[1:0]). when the value of t0, 1 value and the value of t0dr, t1dr are respectively identical in timer 0, 1, the interrupt of timer 0, 1 occurs. the external clock (ec0) counts up the timer at the rising edge. if ec0 is selected from t0ck[2:0], ec0 port becomes input port. the timer 1 can?t use the external ec0 clock. figure 4.6 8 bit timer/event counter0, 1 block diagram 4096 1024 256 p r e s c a l e r mux 2 4 16 64 ec0 fx mux 1 2 16 [b3 h ] t0if timer0 interrupt 8-bit timer0 counter t0(8bit) 8-bit timer0 data register t0dr(8bit) f/f p04/t0 t0cn clear [b3 h ] comparator t0st [b5 h ] t1if timer1 interrupt 8-bit timer1 counter t1(8bit) 8-bit timer1 data register t1dr(8bit) f/f p05/t1 t1cn clear [b6 h ] comparator t1st pol 16bit pwm1e cap1 t1ck1 t1ck0 t1cn t1st t0en t0pe cap0 t0ck2 t0ck1 t0ck0 t0cn t0st t1cr t0cr 1 x 0 x x x x x x 0 0 0 x x x x address : b2 h initial value : 0000_0000 b address : b4 h initial value : 0000_0000 b t0ck[2:0] 3 t1ck[1:0] 2
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 82 4.5.1.3 16-bit timer/counter mode the timer register is being run with all 16bits. a 16-bit timer/counter register t0, t1 are incremented from 0000h to ffffh until it matches t0dr, t1dr and then resets to 0000h. the match output generates the timer 0 interrupt ( no timer 1 interrupt). the clock source is selected from t0ck[2:0] and t1ck[1:0] must set 11b and 16bit bit must set to ?1?. the timer 0 is lsb 8-bit, the timer 1 is msb 8-bit. the 16-bit mode setting is shown as figure 4.9. figure 4.8 operation example of timer/event counter0, 1 t0dr/t1dr value time stop timer 0, 1 (t0if, t1if) interrupt interrupt occurs interrupt occurs clear&start disable enable up-count t0st, t1st start&stop t0st,t1st = 0 t0cn, t1cn control count t0st,t1st = 1 t0st,t1st = 1 t0cn,t1cn = 0 t0cn,t1cn = 1 t0cn,t1cn = 1 figure 4.7 timer/event counter0, 1 example t0dr/t1dr value timer 0, 1 (t0if, t1if) interrupt time 1 2 3 4 5 6 n-2 n-1 n interrupt period = p cp x (n+1) 0 count pulse period p cp up-count match with t0dr/t1dr interrupt occurs interrupt occurs interrupt occurs
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 83 note: do not set t0dr to 0x00 in 16-bit mode. if t0dr is set to 0x00, timer interrupt or count match occur after t1dr+0x01. if you set t0dr to be 0x00, t1dr must have one fewer number of count than the number of count which you want. example: if t1dr=0x01 and t0dr=0x00, counter match occurs when t1=0x02 and t0=0x00. 4.5.1.4 8-bit capture mode the timer 0, 1 capture mode is set by cap0, cap1 as ?1?. the clock source can use the internal/external clock. basically, it has the same function of the 8-bit timer/counter mode and the interrupt occurs at t0, t1 and t0dr, t1dr matching time, respectively. the capture result is loaded into cdr0, cdr1. the t0, t1 value is automatically cleared by hardware and restarts counter. this timer interrupt in capture mode is very useful when the pulse width of captured signal is wider than the maximum period of timer. as the eiedge and eipola register setting, the external interrupt int0, int1 function is chosen. the cdr0, t0 and t0dr are in same address. in the capture mode, reading operation is read the cdr0, not t0dr because path is opened to the cdr0. the cdr1 has the same function. figure 4.9 16 bit timer/event counter0, 1 block diagram 4096 1024 256 p r e s c a l e r mux 2 4 16 64 ec0 fx [b3 h ] t0if timer0 interrupt 16-bit counter 16-bit data register f/f p04/t0 pin t0cn clear [b3 h ] comparator t0st t0ck[2:0] 3 t0 (8bit) t1 (8bit) t0dr (8bit) t1dr (8bit) [b6 h ] [b5 h ] pol 16bit pwm1e cap1 t1ck1 t1ck0 t1cn t1st t0en t0pe cap0 t0ck2 t0ck1 t0ck0 t0cn t0st t1cr t0cr 1 x 0 x x x x x x 1 0 0 1 1 x x address : b2 h initial value : 0000_0000 b address : b4 h initial value : 0000_0000 b
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 84 figure 4.10 8-bit capture mode for timer0, 1 4096 1024 256 p r e s c a l e r mux 2 4 16 64 ec0 fx mux 1 2 16 [b3 h ] int0if int0 interrupt 8-bit timer0 counter t0(8bit) 8-bit timer0 data register t0cn clear [b3 h ] t0st t0ck[2:0] 3 t1ck[1:0] 2 int0 eiedge.0 [b5 h ] int1if int1 interrupt 8-bit timer1 counter t1(8bit) 8-bit timer1 data register t1cn clear [b6 h ] t1st int1 eiedge.1 pol 16bit pwm1e cap1 t1ck1 t1ck0 t1cn t1st t0en t0pe cap0 t0ck2 t0ck1 t0ck0 t0cn t0st t1cr t0cr 1 x 1 x x x x x x 0 0 1 x x x x address : b2 h initial value : 0000_0000 b address : b4 h initial value : 0000_0000 b timer0 interrupt t0if comparator clear timer1 interrupt t1if comparator clear cdr1 (8bit) t1dr (8bit) cdr0 (8bit) t0dr (8bit) [b3 h ] [b6 h ]
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 85 4.5.1.5 16-bit capture mode the 16-bit capture mode is the same operation as 8-bit capture mode, except that the timer register uses 16 bits. the clock source is selected from t0ck[2:0] and t1ck[1:0] must set 11b and 16bit0 bit must set to ?1?. the 16-bit mode setting is shown as figure 4.13. figure 4.12 express timer overflow in capture mode t0, t1 interrupt request (int0f,int1f) x x h interrupt interval period = ff h +01 h +ff h +01 h +yy h +01 h ext. int0,1 pin interrupt request (t0if,t1if) ff h ff h yy h 00 h 00 h 00 h 00 h 00 h figure 4.11 input capture mode operation of timer 0, 1 t0/t1 value interrupt request (int0f,int1f) time 1 2 3 4 5 6 n-2 n-1 n interrupt interval period 0 count pulse period p cp up-count cdr0, cdr1 load ext. int0,1 pin
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 86 4.5.1.6 pwm mode the timer 1 has a pwm (pulse width modulation) f unction. in pwm mode, the t1/pwm1 output pin outputs up to 10-bit resolution pwm output. this pin should be configured as a pwm output by set t1_pe to ?1?. the period of the pwm output is determined by the t1ppr (pwm period register) + t1pwhr[3:2] + t1pwhr[1:0] pwm period = [ t1pwhr[3:2]t1ppr ] x source clock pwm duty = [ t1pwhr[1:0] t1pdr ] x source clock table 4.6 pwm frequency vs. resolution at 8 mhz resolution frequency t1ck[1:0]=00 (125ns) t1ck[1:0]=01 (250ns) t1ck[1:0]=10 (2us) 10 bit 7.8khz 3.9khz 0.49khz 9 bit 15.6khz 7.8khz 0.98khz 8 bit 31.2khz 15.6khz 1.95khz 7 bit 62.4khz 31.2khz 3.91khz the pol bit of t1cr register decides the polarity of duty cycle. if the duty value is set same to the period value, the pwm output is determined by the bit pol (1: high, 0: low). and if the duty value is set to "00h", the pwm output is determined by the bit pol (1: low, 0: high). figure 4.13 16-bit capture mode of timer 0, 1 4096 1024 256 p r e s c a l e r mux 2 4 16 64 ec0 fx int0if int0 interrupt 16-bit counter 16-bit data register t0cn clear [b6 h :b3 h ] t0st t0ck[2:0] 3 int0 eiedge.0 t1(8bit) msb t0(8bit) lsb cdr1(8bit) +cdr0(8bit) t1dr(8bit) +t0dr(8bit) [b6 h :b3 h ][ b 5 h :b3 h ] pol 16bit pwm1e cap1 t1ck1 t1ck0 t1cn t1st t0en t0pe cap0 t0ck2 t0ck1 t0ck0 t0cn t0st t1cr t0cr 1 x 1 x x x x x x 1 0 1 1 1 x x address : c6 h initial value : 0000_0000 b address : ca h initial value : 0000_0000 b t0if comparator clear timer0 interrupt
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 87 figure 4.15 example of pwm at 4mhz source clock (f x ) duty cycle(1+80 h )x250ns = 32.25us t1 00 01 02 03 04 7f 80 81 82 3ff 00 01 02 t1/pwm1 pol = 1 t1/pwm1 pol = 0 period cycle(1+3ff h )x250ns = 256us ? 3.9khz t1ppr(8 bit) t1pdr(8 bit) pw1h3 pw1h2 pw1h1 pw1h0 1 1 ff h 0 0 80 h t1cr[1:0] = 00 h (f xin ) t1pwhr = 03 h t1ppr = ff h t1pdr = 80 h figure 4.14 pwm mode p r e s c a l e r mux t0 clock source fx t1cn t1st t1ck[1:0] 2 1 2 16 8-bit timer3 pwm period register 8-bit timer3 counter + 2-bit clear comparator t1ppr (8 bit) 2 bit t1 (8 bit) [b7 h ] [b6 h ] t1phr[1:0] s q r t1pdr (8 bit) t1phr[7:6] comparator [b6 h ] pol 16bit pwm1e cap1 t1ck1 t1ck0 t1cn t1st t1cr x 0 1 0 x x x x address : b4 h initial value : 0000_0000 b t1pdr (8 bit) [b6 h ] pwm1 pol t1_pe - - - pw1h3 pw1h2 pw1h1 pw1h0 t1pwhr 1 - - - x x x x address : b7 h initial value : 0---_0000 b slave master t1_pe period high duty high
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 88 4.5.1.7 8-bit (16-bit) compare output mode if the t1 (t0+t1) value and the t1dr (t0dr+t1dr) value are matched, t1/pwm1 port outputs. the output is 50:50 of duty square wave, the frequency is following to export the compare output as t1/pwm1, the t1_pe bit in the t1pwhr register must set to ?1?. 4.5.1.8 register map table 4.7 timer register map name address dir default description t 0cr b2h r/w 0 0h t imer 0 mode control register t 0 b3h r 0 0h t imer 0 register t 0dr b3h w ffh t imer 0 data register cdr0 b3h r 0 0h capture 0 data register t 1cr b4h r/w 0 0h t imer 1 mode control register t 1dr b5h w ffh t imer 1 data register t 1ppr b5h w ffh t imer 1 pwm period register t 1 b6h r 0 0h t imer 1 register t 1pdr b6h r/w 0 0h t imer 1 pwm duty register cdr1 b6h r 0 0h capture 1 data register t 1pwhr b7h w 0 0h t imer 1 pwm high register figure 4.16 example of changing the period in absolute duty cycle at 4mhz t1 00 01 02 03 04 t1/pwm pol = 1 t1cr[1:0] = 10 h (2us) t1pwhr = 00 h t1ppr = 0e h t1pdr = 05 h 09 08 0706 05 0d 0c 0b 0a 02 01 00 0e 06 050403 0a 090807 03 02 01 00 05 04 source clock (f x ) 06 duty cycle ( 1+05 h ) x2us = 12us duty cycle ( 1+05 h ) x2us = 12us duty cycle ( 1+05 h ) x2us = 12us period cycle (1+0e h )x2us = 32us ? 31.25khz period cycle (1+0a h )x2us = 22us ? 45.5khz write 0a h to t1ppr )1(value prescaler 2 frequency oscillator ?? ? ? tdr comp f
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 89 4.5.1.9 timer/counter 0, 1 register description the timer/counter 0, 1 register consists of timer 0 mode control register (t0cr), timer 0 register (t0), timer 0 data register (t0dr), capture 0 data register (cdr0), timer 1 mode control register (t1cr), timer 1 data register (t1dr), timer 1 pwm period register (t1ppr), timer 1 register (t1), timer 1 pwm duty register (t1ppr), capture 1 data register (cdr1) and timer 1 pwm high register (t1pwhr). 4.5.1.10 register description for timer/counter 0, 1 t0cr (timer 0 mode control register) : b2h 7 6 5 4 3 2 1 0 t0en t0_pe cap0 t0ck2 t0ck1 t0ck0 t0cn t0st r/w r/w r/w r/w r/w r/w r/w r/w initial value : 00h t0en control timer 0 0 timer 0 disable 1 timer 0 enable t0_pe control timer 0 output port 0 timer 0 output disable 1 timer 0 output enable cap0 control timer 0 operation mode 0 timer/counter mode 1 capture mode t0ck[2:0] select timer 0 clock source. fx is main system clock frequency t0ck2 t0ck1 t0ck0 description 0 0 0 fx/2 0 0 1 fx/2^2 0 1 0 fx/2^4 0 1 1 fx/2^6 1 0 0 fx/2^8 1 0 1 fx/2^10 1 1 0 fx/2^12 1 1 1 external clock (ec0) t0cn control timer 0 count pause/continue 0 temporary count stop 1 continue count t0st control timer 0 start/stop 0 counter stop 1 clear counter and start
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 90 t0 (timer 0 register: read case) : b3h 7 6 5 4 3 2 1 0 t07 t06 t05 t04 t03 t02 t01 t00 r r r r r r r r initial value : 00h t0[7:0] t0 counter data t0dr (timer 0 data register: write case) : b3h 7 6 5 4 3 2 1 0 t0d7 t0d6 t0d5 t0d4 t0d3 t0d2 t0d1 t0d0 w w w w w w w w initial value : ffh t0d[7:0] t0 compare data cdr0 (capture 0 data register: read case) : b3h 7 6 5 4 3 2 1 0 cdr07 cdr06 cdr05 cdr04 cdr03 cdr02 cdr01 cdr00 r r r r r r r r initial value : 00h cdr0[7:0] t0 capture data t1cr (timer 1 mode count register) : b4h 7 6 5 4 3 2 1 0 pol 16bit pwm1e cap1 t1ck1 t1ck0 t1cn t1st r/w r/w r/w r/w r/w r/w r/w r/w initial value : 00h pol configure pwm polarity 0 negative (duty match: clear) 1 positive (duty match: set) 16bit select timer 1 8/16bit 0 8 bit 1 16 bit pwm1e control pwm enable 0 pwm disable 1 pwm enable cap1 control timer 1 mode 0 timer/counter mode 1 capture mode t1ck[1:0] select clock source of timer 1. fx is the frequency of main system. t1ck1 t1ck0 description 0 0 fx 0 1 fx/2 1 0 fx/2^4
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 91 1 1 use timer 0 clock t1cn control timer 1 count pause/continue 0 temporary count stop 1 continue count t1st control timer 1 start/stop 0 counter stop 1 clear counter and start t1dr (timer 1 data register: write case) : b5h 7 6 5 4 3 2 1 0 t1d7 t1d6 t1d5 t1d4 t1d3 t1d2 t1d1 t1d0 w w w w w w w w initial value : ffh t1d[7:0] t1 compare data t1ppr (timer 1 pwm period register: write case) : b5h 7 6 5 4 3 2 1 0 t1pp7 t1pp6 t1pp5 t1pp4 t1pp3 t1pp2 t1pp1 t1pp0 w w w w w w w w initial value : ffh t1pp[7:0] t1 pwm period data t1 (timer 1 register: read case) : b6h 7 6 5 4 3 2 1 0 t17 t16 t15 t14 t13 t12 t11 t10 r r r r r r r r initial value : 00h t1[7:0] t1 counter period data t1pdr (timer 1 pwm duty register) : b6h 7 6 5 4 3 2 1 0 t1pd7 t1pd6 t1pd5 t1pd4 t1pd3 t1pd2 t1pd1 t1pd0 r/w r/w r/w r/w r/w r/w r/w r/w initial value : 00h t1pd[7:0] t1 pwm duty data note) only write, when pwm1e ?1? cdr1 (capture 1 data register: read case) : b6h 7 6 5 4 3 2 1 0 cdr17 cdr16 cdr15 cdr14 cdr13 cdr12 cdr11 cdr10 r r r r r r r r initial value : 00h cdr1[7:0] t1 capture data
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 92 t1pwhr (timer 1 pwm high register) : b7h 7 6 5 4 3 2 1 0 t1_pe - - - pw1h3 pw1h2 pw1h1 pw1h0 w - - - w w w w initial value : 00h t1_pe control timer 1 output port operation note) only writable bit. be careful 0 timer 1 output disable 1 timer 1 output enable pw1h[3:2] pwm period high value (bit [9:8]) pw1h[1:0] pwm duty high value (bit [9:8]) period: pw1h3 pw1h2 t1ppr[7:0] duty: pw1h1 pw1h0 t1pdr[7:0] tflg (timer interrupt flag register) : 97h 7 6 5 4 3 2 1 0 - - t1if t0if - - - - - - r/w r/w - - - - initial value : 00h t1if timer1 interrupt flag t0if timer0 interrupt flag 4.5.2 16-bit timer 4 4.5.2.1 overview the 16-bit timer 4 consists of multiplexer, timer data register high/low, timer register high/low, timer mode control register. it is able to use inte rnal 16-bit timer/ counter without a port output function. the 16-bit timer 4 is able to use the divided clock of the main clock selected from prescaler output.
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 93 4.5.2.2 16 bit timer/counter mode 4.5.2.3 register map table 4-8 register map name address dir default description t 4cr 0xce r/w 0h t imer 4 mode control register t 4l 0xcf r 0h t imer 4 low register t 4ldr 0xcf w ffh t imer 4 low data register t 4h 0xcd r 0h t imer 4 high register t 4hdr 0xcd r/w 0h t imer 4 high data register 4.5.2.4 timer 4 register description the timer 4 register consists of timer 4 mode control register (t4cr), timer 4 low register (t4l), timer 4 low data register (t4ldr), timer 4 high register (t4h), timer 4 high data register (t4hdr). 4.5.2.5 register description for timer 4 t4cr (timer 4 mode control register) : ceh 7 6 5 4 3 2 1 0 t4en - - t4ck2 t4ck1 t4ck0 t4cn t4st figure 4.17 timer4 16-bit mode block diagram 1024 256 64 p r e s c a l e r mux 2 4 8 16 fx [cd h ] t4if timer4 interrupt 16-bit timer4 counter 16-bit timer4 data register t4cn clear [cd h ] comparator t4st t4ck[2:0] 3 t4h (8bit) t4l (8bit) t4hdr (8bit) t4ldr (8bit) [cf h ] [cf h ] t4en - - t4ck2 t4ck1 t4ck0 t4cn t4st t4cr 1 - - x x x x x address : ce h initial value : 0--0_0000 b 2048
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 94 r/w - - r/w r/w r/w r/w r/w initial value : 00h t4en control timer 4 operation 0 timer 4 disable 1 timer 4 enable t4ck[2:0] select timer 4 clock source. fx is main system clock frequency t4ck2 t4ck1 t4ck0 description 0 0 0 fx/2 0 0 1 fx/4 0 1 0 fx/8 0 1 1 fx/16 1 0 0 fx/64 1 0 1 fx/256 1 1 0 fx/1024 1 1 1 fx/2048 t4cn control timer 4 count pause/continue 0 temporary count stop 1 continue count t4st control timer 4 start/stop 0 counter stop 1 clear counter and start t4l (timer 4 low register: read case) : cfh 7 6 5 4 3 2 1 0 t4l7 t4l6 t4l5 t4l4 t4l3 t4l2 t4l1 t4l0 r r r r r r r r initial value : 00h t4l[7:0] t4l counter t4ldr (timer 4 low data register: write case) : cfh 7 6 5 4 3 2 1 0 t4ld7 t4ld6 t4ld5 t4ld4 t4ld3 t4ld2 t4ld1 t4ld0 w w w w w w w w initial value : ffh t4ld[7:0] t4l compare t4h (timer 4 high register: read case) : cdh 7 6 5 4 3 2 1 0 t4h7 t4h6 t4h5 t4h4 t4h3 t4h2 t4h1 t4h0 r r r r r r r r initial value : 00h t4h[7:0] t4h counter period t4hdr (timer 4 high data register: write case) : cdh 7 6 5 4 3 2 1 0
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 95 t4hd7 t4hd6 t4hd5 t4hd4 t4hd3 t4hd2 t4hd1 t4hd0 w w w w w w w w initial value : ffh t4hd[7:0] t4h compare tflg (timer interrupt flag register) : 97h 7 6 5 4 3 2 1 0 - t4if - - - - - - - r/w - - - - - - initial value : 00h t4if timer4 interrupt flag
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 96 4.6 usart 4.6.1 overview the universal synchronous and asynchronous serial receiver and transmitter (usart) is a highly flexible serial communication device. the main features are listed below. - full duplex operation (independent serial receive and transmit registers) - asynchronous or synchronous operation - master or slave clocked synchronous and spi operation - supports all four spi modes of operation (mode 0, 1, 2, 3) - lsb first or msb first data transfer @spi mode - high resolution baud rate generator - supports serial frames with 5,6,7,8, or 9 data bits and 1 or 2 stop bits - odd or even parity generation and parity check supported by hardware - data overrun detection - framing error detection - digital low pass filter - three separate interrupts on tx complete, tx data register empty and rx complete - double speed asynchronous communication mode usart has three main parts of clock generator, transmitter and receiver. the clock generation logic consists of synchronization logic for external clock input used by synchronous or spi slave operation, and the baud rate generator for asynchronous or master (synchronous or spi) operation. the transmitter consists of a single write buffer, a serial shift register, parity generator and control logic for handling different serial frame formats. the write buffer allows a continuous transfer of data without any delay between frames. the receiver is the most complex part of the usart module due to its clock and data recovery units. the recovery unit is used for asynchronous data reception. in addition to the recovery unit, the receiver includes a parity checker, a shift register, a two level receive fifo (udatan) and control logic. the receiver supports the same frame formats as the transmitter and can detect frame error, data overrun and parity errors.
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 97 4.6.2 block diagram figure 4.18 usart block diagram xck xck control clock sync logic ubaud rxd/ miso txd/ mosi m u x m u x tx control rx control clock recovery receive shift register (rxsr) data recovery dor/pe/fe checker udata[0] (rx) udata[1] (rx) parity generator stop bit generator d e p udata(tx) transmit shift register (txsr) m u x m u x ss ss control rxc txc umsel1 umsel0 upm1 upm0 usize2 usize1 usize0 ucpol uctrl1 address : e2 h initial value : 0000_0000 b udrie txcie rxcie wakeie txe rxe usarten u2x uctrl2 address : e3 h initial value : 0000_0000 b master loops disxck spiss - usbs tx8 rx8 uctrl3 address : e4 h initial value : 0000_-000 b udre txc rxc wake softrst dor fe pe ustat address : e5 h initial value : 1000_0000 b sclk m u x rx interrupt rx interrupt i n t e r n a l b u s l i n e d e p umsel1&umsel0 master upm1 upm0 umsel0 master umsel[1:0] baud rate generator
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 98 4.6.3 clock generation clock generation ?? transmitter & receiver ? ???? ?? clock ? ????? the clock generation logic generates the base clock for the transmitter and receiver. the usart supports four modes of clock operation and those are normal asynchronous, double speed asynchronous, master synchronous and slave synchronous. the clock generation scheme for master spi and slave spi mode is the same as master synchronous and slave synchronous operation mode. the umseln bit in uctrl1 register selects between asynchronous and synchronous operation. asynchronous double speed mode is controlled by the u2x bit in the uctrl2 register. the master bit in uctrl2 register controls whether the clock source is internal (master mode, output port) or external (slave mode, input port). the xck pin is only active when the usart operates in synchronous or spi mode. table below contains equations for calculating the baud rate (in bps). table 4.9 equations for calculating baud rate register setting operating mode equation for calculating baud rate asynchronous normal mode (u2x=0) baud rate fsclk 16ubaud 1 asynchronous double speed mode (u2x=1) baud rate fsclk 8ubaud 1 synchronous or spi master mode baud rate fsclk 2ubaud 1 figure 4.19 clock generation block diagram xck prescaling up-counter ubaud /2 /8 sync register m u x m u x m u x m u x /2 edge detector sclk f sclk (ubaud+1) txclk rxclk umsel0 u2x master ucpol
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 99 4.6.4 external clock (xck) external clocking is used by the synchronous or spi slave modes of operation. external clock input from the xck pin is sampled by a synchronization logic to remove meta-stability. the output from the synchronization logic must then pass through an edge detector before it can be used by the transmitter and receiver. this process introduces a two cpu clock period delay and therefore the maximum frequency of the external xck pin is limited by the following equation. fxck fsclk 4 where fxck is the frequency of xck and fsclk is the frequency of main system clock (sclk). 4.6.5 synchronous mode operation when synchronous or spi mode is used, the xck pin will be used as either clock input (slave) or clock output (master). the dependency between the clock edges and data sampling or data change is the same. the basic principle is that data input on rxd (miso in spi mode) pin is sampled at the opposite xck clock edge of the edge in the data output on txd (mosi in spi mode) pin is changed. the ucpol bit in uctrl1 register selects which xck clock edge is used for data sampling and which is used for data change. as shown in the figure below, when ucpol is zero the data will be changed at rising xck edge and sampled at falling xck edge. 4.6.6 data format a serial frame is defined to be one character of data bits with synchronization bits (start and stop bits), and optionally a parity bit for error checking. the usart supports all 30 combinations of the following as valid frame formats. - 1 start bit - 5, 6, 7, 8 or 9 data bits - no, even or odd parity bit - 1 or 2 stop bits figure 4.20 synchronous mode xckn timing. xck txd/rxd ucpol = 1 txd/rxd xck ucpol = 0 sample sample
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 100 a frame starts with the start bit followed by the least significant data bit (lsb). then the next data bits, up to a total of nine, are succeeding, ending with the most significant bit (msb). if enabled the parity bit is inserted after the data bits, before the stop bits. a high to low transition on data pin is considered as start bit. when a complete frame is transmitted, it can be directly followed by a new frame, or the communication line can be set to an idle state. the idle means high state of data pin. the next figure shows the possible combinations of the frame formats. bits inside brackets are optional. 1 data frame consists of the following bits ? idle no communication on communication line (txd/rxd) ? st start bit (low) ? dn data bits (0~8) ? parity bit ------------ even parity, odd parity, no parity ? stop bit(s) ---------- 1 bit or 2 bits the frame format used by the usart is set by th e usize[2:0], upm[1:0] an d usbs bits in uctrl1 register. the transmitter and receiver use the same setting. 4.6.7 priority bit the parity bit is calculated by doing an exclusive-or of all the data bits. if odd parity is used, the result of the exclusive-or is inverted. the parity bit is located between the msb and first stop bit of a serial frame. p even = d n-1 ^ ? ^ d 3 ^ d 2 ^ d 1 ^ d 0 ^ 0 p odd = d n-1 ^ ? ^ d 3 ^ d 2 ^ d 1 ^ d 0 ^ 1 p even : parity bit using even parity p odd : parity bit using odd parity d n : data bit n of the character 4.6.8 usart transmitter the usart transmitter is enabled by setting the txe bit in uctrl1 register. when the transmitter is enabled, the normal port operation of the txd pin is overridden by the serial output pin of usart. the baud-rate, operation mode and frame format must be setup once before doing any transmissions. if synchronous or spi operation is used, the clock on the xck pin will be overridden and used as transmission clock. if usart operates in spi mode, ss pin is used as ss input pin in slave mode or can be configured as ss output pin in master mode. this can be done by setting spiss bit in uctrl3 register. figure 4.21 frame format [d7] [d6] [d5] d4 d3 d2 d1 d0 [d8] [p] idle st sp1 [sp2 ] idle / st 1 data frame character bits
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 101 note: in tx mode, the length of start bit can be shorter than one or two clock of the lengh of the other data bits. 4.6.8.1 sending tx data a data transmission is initiated by loading the tran smit buffer (udata register i/o location) with the data to be transmitted. the data written in transmit buffer is moved to the shi ft register when the shift register is ready to send a new frame. the shift register is loaded with the new data if it is in idle state or immediately after the last stop bit of the previous frame is transmitted. when the shift register is loaded with new data, it will transfer one complete frame at the settings of control registers. if the 9-bit characters are used in asynchronous or synchronous operation mode (usize[2:0]=7), the ninth bit must be written to the tx8 bit in uctrl3 register before loading transmit buffer (udata register). 4.6.8.2 transmitter flag and interrupt the usart transmitter has 2 flags which indicate its state. one is usart data register empty (udre) and the other is transmit complete (txc). both flags can be interrupt sources. udre flag indicates whether the transmit buffer is re ady to receive new data. this bit is set when the transmit buffer is empty and cleared when the transmit buffer contains data to be transmitted that has not yet been moved into the shift register. and also this flag can be cleared by writing ?0? to this bit position. writing ?1? to this bit position is prevented. when the data register empty interrupt enable (udrie) bit in uctrl2 register is set and the global interrupt is enabled, usart data register empty interrupt is generated while udre flag is set. the transmit complete (txc) flag bit is set when the entire frame in the transmit shift register has been shifted out and there are no more data in t he transmit buffer. the txc flag is automatically cleared when the transmit complete interrupt service routine is executed, or it can be cleared by writing ?0? to txc bit in uctrl2 register. when the transmit complete interrupt enable (txcie) bit in uctrl2 register is set and the global interrupt is enabled, usart transmit complete interrupt is generated while txc flag is set. 4.6.8.3 parity generator the parity generator calculates the parity bit for the sending serial frame data. when parity bit is enabled (upm[1]=1), the transmitter control logic inse rts the parity bit between the msb and the first stop bit of the sending frame. 4.6.8.4 disabling transmitter disabling the transmitter by clearing the txe bit will not become effective until ongoing transmission is completed. when the transmitter is disabled, the txd pin is used as normal general purpose i/o (gpio) or primary function pin. 4.6.9 usart receiver the usart receiver is enabled by setting the rxe bit in the uctrl1 register. when the receiver is enabled, the normal pin operation of the rxd pin is overridden by the usart as the serial input pin of the receiver. the baud-rate, mode of operation and frame format must be set before serial reception. if synchronous or spi operation is used, the clock on the xck pin will be used as transfer clock. if usart operates in spi mode, ss pin is used as ss input pin in slave mode or can be
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 102 configured as ss output pin in master mode. this can be done by setting spiss bit in uctrl3 register. 4.6.9.1 receiving rx data when usart is in synchronous or asynchronous operation mode, the receiver starts data reception when it detects a valid start bit (low) on rxd pin. each bit after start bit is sampled at pre- defined baud-rate (asynchronous) or sampling edge of xck (synchronous), and shifted into the receive shift register until the first stop bit of a frame is received. even if there?s 2 nd stop bit in the frame, the 2 nd stop bit is ignored by the receiver. that is, receiving the first stop bit means that a complete serial frame is present in the receiver shift register and contents of the shift register are to be moved into the receive buffer. the receive buffer is read by reading the udata register. if 9-bit characters are used (usize[2:0] = 7) the ninth bit is stored in the rx8 bit position in the uctrl3 register. the 9 th bit must be read from the rx8 bit before reading the low 8 bits from the udata register. likewise, the error flags fe, dor, pe must be read before reading the data from udata register. this is because the error flags are stored in the same fifo position of the receive buffer. 4.6.9.2 receiver flag and interrupt the usart receiver has one flag that indicates the receiver state. the receive complete (rxc) flag indicates whether there are unread data present in the receive buffer. this flag is set when there are unread data in the receive buffer and cleared when the receive buffer is empty. if the receiver is disabled (rxe=0) , the receiver buffer is flushed and the rxc flag is cleared. when the receive complete interrupt enable (rxcie) bit in the uctrl2 register is set and global interrupt is enabled, the usart receiver complete interrupt is generated while rxc flag is set. the usart receiver has three error flags which are frame error (fe), data overrun (dor) and parity error (pe). these error flags can be read from the ustat register. as data received are stored in the 2-level receive buffer, these error flags are also stored in the same position of receive buffer. so, before reading received data from udata register, read the ustat register first which contains error flags. the frame error (fe) flag indicates the state of the first stop bit. the fe flag is zero when the stop bit was correctly detected as one, and the fe flag is one when the stop bit was incorrect, ie detected as zero. this flag can be used for detecting out-of-sync conditions between data frames. the data overrun (dor) flag indicates data loss due to a receive buffer full condition. a dor occurs when the receive buffer is full, and another new data is present in the receive shift register which are to be stored into the receive buffer. after the dor flag is set, all the incoming data are lost. to prevent data loss or clear this flag, read the receive buffer. the parity error (pe) flag indica tes that the frame in the receive buffer had a parity error when received. if parity check function is not enabled (upm[1]=0), the pe bit is always read zero. note) the error flags related to receive operation are not used when usart is in spi mode. 4.6.9.3 parity checker if parity bit is enabled (upm[1]=1), the parity checker calculates the parity of the data bits in incoming frame and compares the result with the parity bit from the received serial frame.
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 103 4.6.9.4 disabling receiver in contrast to transmitter, disabling the receiver by clearing rxe bit makes the receiver inactive immediately. when the receiver is disabled the receiver flushes the receive buffer and the remaining data in the buffer is all reset. the rxd pin is not overridden the function of usart, so rxd pin becomes normal gpio or primary function pin. 4.6.9.5 asynchronous data reception to receive asynchronous data frame, the usart includes a clock and data recovery unit. the clock recovery logic is used for synchronizing the inte rnally generated baud-rate clock to the incoming asynchronous serial frame on the rxd pin. the data recovery logic samples and low pass filters the incoming bits, and this removes the noise of rxd pin. the next figure illustrates the sampling process of the start bit of an incoming frame. the sampling rate is 16 times the baud-rate for normal mode, and 8 times the baud rate for double speed mode (u2x=1). the horizontal arrows show the synchroni zation variation due to the asynchronous sampling process. note that larger time variation is shown when using the double speed mode. when the receiver is enabled (rxe=1), the clock recovery logic tries to find a high to low transition on the rxd line, the start bit condition. after dete cting high to low transition on rxd line, the clock recovery logic uses samples 8,9, and 10 for normal mode, and samples 4, 5, and 6 for double speed mode to decide if a valid start bit is received. if more than 2 samples have logical low level, it is considered that a valid start bit is detected and the internally generated clock is synchronized to the incoming data frame. and the data recovery can begin. the synchronization process is repeated for each start bit. as described above, when the receiver clock is synchronized to the start bit, the data recovery can begin. data recovery process is almost similar to the clock recovery process. the data recovery logic samples 16 times for each incoming bits for normal mode and 8 times for double speed mode. and uses sample 8, 9, and 10 to decide data value for normal mode, samples 4, 5, and 6 for double speed mode. if more than 2 samples have low levels, the received bit is considered to a logic 0 and more than 2 samples have high levels, the received bit is considered to a logic 1. the data recovery process is then repeated until a complete frame is received including the first stop bit. the decided bit value is stored in the receive shift register in order. note that the receiver only uses the first stop bit of a frame. internally, after receiving the first stop bit, the receiver is in idle state and waiting to find start bit. figure 4.22 start bit sampling rxd 0 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 1 2 3 idle bit0 start 0 1 2 3 4 5 6 7 8 1 2 sample (u2x = 0) sample (u2x = 1)
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 104 the process for detecting stop bit is like clock and data recovery process. that is, if 2 or more samples of 3 center values have high level, correct stop bit is detected, else a frame error flag is set. after deciding first stop bit whether a valid stop bit is received or not, the receiver goes idle state and monitors the rxd line to check a valid high to low transition is detected (start bit detection). 4.6.10 spi mode the usart can be set to operate in industrial standard spi compliant mode. the spi mode has the following features. - full duplex, three-wire synchronous data transfer - master or slave operation - supports all four spi modes of operation (mode0, 1, 2, and 3) - selectable lsb first or msb first data transfer - double buffered transmit and receive - programmable transmit bit rate when spi mode is enabled (umsel[1:0]=3), the slave select (ss) pin becomes active low input in slave mode operation, or can be output in master mode operation if spiss bit is set. note that during spi mode of operation, the pi n rxd is renamed as miso and txd is renamed as mosi for compatibility to other spi devices. 4.6.10.1 spi clock formats and timing to accommodate a wide variety of synchronous serial peripherals from different manufacturers, the usart has a clock polarity bit (ucpol) and a clock phase control bit (ucpha) to select one of four clock formats for data transfers. ucpol selectively in sert an inverter in series with the clock. ucpha chooses between two different clock phase relationships between the clock and data. note that figure 4.24 stop bit sampling and next start bit sampling rxd 1 2 3 4 5 6 7 8 9 10 11 12 13 stop 1 1 2 3 4 5 6 7 sample (u2x = 0) sample (u2x = 1) (a) (b) (c) figure 4.23 sampling of data and parity bit rxd 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 1 bit n 1 2 3 4 5 6 7 8 1 sample (u2x = 0) sample (u2x = 1)
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 105 ucpha and ucpol bits in uctrl1 register have different meanings according to the umsel[1:0] bits which decides the operating mode of usart. table below shows four combinations of ucpol and ucpha for spi mode 0, 1, 2, and 3. table 4.10 cpol functionality spi mode ucpol ucpha leading edge trailing edge 0 0 0 sample (rising) setup (falling) 1 0 1 setup (rising) sample (falling) 2 1 0 sample (falling) setup (rising) 3 1 1 setup (falling) sample (rising) when ucpha=0, the slave begins to drive its miso output with the first data bit value when ss goes to active low. the first xck edge causes both the master and the slave to sample the data bit value on their miso and mosi inputs, respectively. at the second xck edge, the usart shifts the second data bit value out to the mosi and miso outputs of the master and slave, respectively. unlike the case of ucpha=1, when ucpha=0, the slave?s ss input must go to its inactive high level between transfers. this is because the slave can prepare the first data bit when it detects falling edge of ss input. figure 4.25 spi clock formats when ucpha=0 xck (ucpol=1) miso mosi xck (ucpol=0) /ss out (master) bit7 bit0 /ss in (slave) bit6 bit1 ? ? bit2 bit5 bit0 bit7 bit1 bit6 sample msb first lsb first
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 106 when ucpha=1, the slave begins to drive its miso output when ss goes active low, but the data is not defined until the first xck edge. the first xck edge shifts the first bit of data from the shifter onto the mosi output of the master and the miso output of the slave. the next xck edge causes both the master and slave to sample the data bit value on their miso and mosi inputs, respectively. at the third xck edge, the usart shifts the second data bit value out to the mosi and miso output of the master and slave respectively. when ucpha=1, the slave?s ss input is not required to go to its inactive high level between transfers. because the spi logic reuses the usart resources, spi mode of operation is similar to that of synchronous or asynchronous operation. an spi transfer is initiated by checking for the usart data register empty flag (udre=1) and then writing a byte of data to the udata register. in master mode of operation, even if transmission is not enabl ed (txe=0), writing data to the udata register is necessary because the clock xck is generated from transmitter block. 4.6.11 register map table 4.11 usart register map name address dir default description uctrl1 e2h r/w 00h usart control 1 register uctrl2 e3h r/w 00h usart control 2 register uctrl3 e4h r/w 00h usart control 3 register ustat e5h r 80h usart status register ubaud e6h r/w ffh usart baud rate generation register udat a e7h r/w ffh usart data register figure 4.26 spi clock formats when ucpha=1 xck (ucpol=1) miso mosi xck (ucpol=0) /ss out (master) bit7 bit0 /ss in (slave) bit6 bit1 ? ? bit2 bit5 bit0 bit7 bit1 bit6 sample msb first lsb first
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 107 4.6.12 usart register description usart module consists of usart control 1 register (uctrl1), usart control 2 register (uctrl2), usart control 3 register (uctrl3), usart status register (ustat), usart data register (udata), and usart baud rate generation register (ubaud). 4.6.13 register description for usart uctrl1 (usart control 1 register) : e2h 7 6 5 4 3 2 1 0 umsel1 umsel0 upm1 upm0 usize2 usize1 udord usize0 ucpha ucpol r/w r/w r/w r/w r/w r/w r/w r/w initial value : 00h umsel[1:0] selects operation mode of usart. umsel1 umsel0 operation mode 0 0 a synchronous mode (uart) 0 1 synchronous mode 1 0 reserved 1 1 spi mode upm[1:0] selects parity generation and check methods upm1 upm0 parity 0 0 no parity 0 1 reserved 1 0 even parity 1 1 odd parity usize[2:0] when in asynchronous or synchronous mode of operation, selects the length of data bits in frame. usize2 usize1 usize0 data length 0 0 0 5 bit 0 0 1 6 bit 0 1 0 7 bit 0 1 1 8 bit 1 0 0 reserved 1 0 1 reserved 1 1 0 reserved 1 1 1 9 bit udord this bit is in the same bit position with usize1. in spi mode, when set to one the msb of the data byte is transmitted first. when set to zero the lsb of the data byte is transmitted first. 0 lsb first 1 msb first ucpol selects polarity of xck in synchronous or spi mode 0 txd change @rising edge, rxd change @falling edge 1 txd change @ falling edge, rxd change @ rising edge ucpha this bit is in the same bit position with usize0. in spi mode, along with ucpol bit, selects one of two clock formats for different kinds of synchronous serial peripherals. leading edge means first xck edge and trailing edge means 2 nd or last clock edge of xck in one xck pulse. and sample means detecting of incoming receive bit, setup means preparing transmit data.
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 108 ucpol ucpha leadi ng edge trailing edge 0 0 sample (rising) setup (falling) 0 1 setup (rising) sample (falling) 1 0 sample (falling) setup (rising) 1 1 setup (falling) sample (rising) uctrl2 (usart control 2 register) : e3h 7 6 5 4 3 2 1 0 udrie txcie rxcie wakeie txe rxe usarten u2x r/w r/w r/w r/w r/w r/w r/w r/w initial value : 00h udrie interrupt enable bit for usart data register empty. 0 interrupt from udre is inhibited (use polling) 1 when udre is set, request an interrupt txcie interrupt enable bit for transmit complete. 0 interrupt from txc is inhibited (use polling) 1 when txc is set, request an interrupt rxcie interrupt enable bit for receive complete 0 interrupt from rxc is inhibited (use polling) 1 when rxc is set, request an interrupt wakeie interrupt enable bit for asynchronous wake in stop mode. when device is in stop mode, if rxd goes to low level an interrupt can be requested to wake-up system. 0 interrupt from wake is inhibited 1 when wake is set, request an interrupt txe enables the transmitter unit. 0 transmitter is disabled 1 transmitter is enabled rxe enables the receiver unit. 0 receiver is disabled 1 receiver is enabled usarten a ctivate usart module by supplying clock. 0 usart is disabled (clock is halted) 1 usart is enabled u2x this bit only has effect for the asynchronous operation and selects receiver sampling rate. 0 normal asynchronous operation 1 double speed asynchronous operation uctrl3 (usart control 3 register) : e4h 7 6 5 4 3 2 1 0 master loops disxck spiss - usbs tx8 rx8 r/w r/w r/w r/w - r/w r/w r/w initial value : 00h master selects master or slave in spi or synchronous mode operation and controls the direction of xck pin. 0 slave mode operation and xck is input pin. 1 master mode operation and xck is output pin
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 109 loops controls the loop back mode of usart, for test mode 0 normal operation 1 loop back mode disxck in synchronous mode of operation, selects the waveform of xck output. 0 xck is free-running while usart is enabled in synchronous master mode. 1 xck is active while any frame is on transferring. spiss controls the functionality of ss pin in master spi mode. 0 ss pin is normal gpio or other primary function 1 ss output to other slave device usbs selects the length of stop bit in asynchronous or synchronous mode of operation. 0 1 stop bit 1 2 stop bit tx8 the ninth bit of data frame in asynchronous or synchronous mode of operation. write this bit first before loading the udata register. 0 msb (9 th bit) to be transmitted is ?0? 1 msb (9 th bit) to be transmitted is ?1? rx8 the ninth bit of data frame in asynchronous or synchronous mode of operation. read this bit first before reading the receive buffer. 0 msb (9 th bit) received is ?0? 1 msb (9 th bit) received is ?1? ustat (usart status register) : e5h 7 6 5 4 3 2 1 0 udre txc rxc wake softrst dor fe pe r/w r/w r/w r/w r/w r r r initial value : 80h udre the udre flag indicates if the transmit buffer (udata) is ready to receive new data. if udre is ?1?, the buffer is empty and ready to be written. this flag can generate a udre interrupt. 0 transmit buffer is not empty. 1 transmit buffer is empty. txc this flag is set when the entire frame in the transmit shift register has been shifted out and there is no new data currently present in the transmit buffer. this flag is automatically cleared when the interrupt service routine of a txc interrupt is executed. this flag can generate a txc interrupt. 0 transmission is ongoing. 1 transmit buffer is empty and the data in transmit shift register are shifted out completely. rxc this flag is set when there are unread data in the receive buffer and cleared when all the data in the receive buffer are read. the rxc flag can be used to generate a rxc interrupt. 0 there is no data unread in the receive buffer 1 there are more than 1 data in the receive buffer wake this flag is set when the rx pin is detected low while the cpu is in stop mode. this flag can be us ed to generate a wake in terrupt. this bit is set only when in asynchronous mode of operation. 0 no wake interrupt is generated. 1 wake interrupt is generated softrst this is an internal reset and only has effect on usart. writing ?1? to this
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 110 bit initializes the internal logic of usart and is auto cleared. 0 no operation 1 reset usart dor this bit is set if a data overrun occurs. while this bit is set, the incoming data frame is ignored. this flag is valid until the receive buffer is read. 0 no data overrun 1 data overrun detected fe this bit is set if the first stop bit of next character in the receive buffer is detected as ?0?. this bit is valid until the receive buffer is read. 0 no frame error 1 frame error detected pe this bit is set if the next character in the receive buffer has a parity error when received while parity checking is enabled. this bit is valid until the receive buffer is read. 0 no parity error 1 parity error detected ubaud (usart baud-rate generation register) : e6h 7 6 5 4 3 2 1 0 ubaud7 ubaud 6 ubaud 5 ubaud 4 ubaud 3 ubaud 2 ubaud 1 ubaud 0 r/w r/w r/w r/w r/w r/w r/w r/w initial value : ffh ubaud [7:0] the value in this register is used to generate internal baud rate in asynchronous mode or to generate xck clock in synchronous or spi mode. to prevent malfunction, do not write ?0? in asynchronous mode, and do not write ?0? or ?1? in synchronous or spi mode. udata (usart data register) : e7h 7 6 5 4 3 2 1 0 udata7 udata6 udata 5 udata 4 udata 3 udata 2 udata 1 udata 0 r/w r/w r/w r/w r/w r/w r/w r/w initial value : ffh udata [7:0] the usart transmit buffer and receive buffer share the same i/o address with this data register. the transmit data buffer is the destination for data written to the udata register. reading the udata register returns the contents of the receive buffer. write this register only when the udre flag is set. in spi or synchronous master mode, write this register even if tx is not enabled to generate clock, xck. 4.6.14 baud rate setting (example) table 4.12 examples of ubaud settings for commonly used oscillator frequencies baud rate fosc=1.00mhz fosc=1.8432mhz fosc=2.00mhz u2x=0 u2x=1 u2x=0 u2x=1 u2x=0 u2x=1 ubaud error ubaud error ubaud error ubaud error ubaud error ubaud error 2400 25 0.2% 51 0.2% 47 0.0% 95 0.0% 51 0.2% 103 0.2% 4800 12 0.2% 25 0.2% 23 0.0% 47 0.0% 25 0.2% 51 0.2% 9600 6 -7.0% 12 0.2% 11 0.0% 23 0.0% 12 0.2% 25 0.2% 14.4k 3 8.5% 8 -3.5% 7 0.0% 15 0.0% 8 -3.5% 16 2.1%
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 111 19.2k 2 8.5% 6 -7.0% 5 0.0% 11 0.0% 6 -7.0% 12 0.2% 28.8k 1 8.5% 3 8.5% 3 0.0% 7 0.0% 3 8.5% 8 -3.5% 38.4k 1 -18.6% 2 8.5% 2 0.0% 5 0.0% 2 8.5% 6 -7.0% 57.6k - - 1 8.5% 1 -25.0% 3 0.0% 1 8.5% 3 8.5% 76.8k - - 1 -18.6% 1 0.0% 2 0.0% 1 -18.6% 2 8.5% 115.2k - - - - - - 1 0.0% - - 1 8.5% 230.4k - - - - - - - - - - - - table 4.13 examples of ubaud settings for commonly used oscillator frequencies (continued) baud rate fosc=3.6864mhz fosc=4.00mhz fosc=7.3728mhz u2x=0 u2x=1 u2x=0 u2x=1 u2x=0 u2x=1 ubaud error ubaud error ubaud error ubaud error ubaud error ubaud error 2400 95 0.0% 191 0.0% 103 0.2% 207 0.2% 191 0.0% - - 4800 47 0.0% 95 0.0% 51 0.2% 103 0.2% 95 0.0% 191 0.0% 9600 23 0.0% 47 0.0% 25 0.2% 51 0.2% 47 0.0% 95 0.0% 14.4k 15 0.0% 31 0.0% 16 2.1% 34 -0.8% 31 0.0% 63 0.0% 19.2k 11 0.0% 23 0.0% 12 0.2% 25 0.2% 23 0.0% 47 0.0% 28.8k 7 0.0% 15 0.0% 8 -3.5% 16 2.1% 15 0.0% 31 0.0% 38.4k 5 0.0% 11 0.0% 6 -7.0% 12 0.2% 11 0.0% 23 0.0% 57.6k 3 0.0% 7 0.0% 3 8.5% 8 -3.5% 7 0.0% 15 0.0% 76.8k 2 0.0% 5 0.0% 2 8.5% 6 -7.0% 5 0.0% 11 0.0% 115.2k 1 0.0% 3 0.0% 1 8.5% 3 8.5% 3 0.0% 7 0.0% 230.4k - - 1 0.0% - - 1 8.5% 1 0.0% 3 0.0% 250k - - 1 -7.8% - - 1 0.0% 1 -7.8% 3 -7.8% 0.5m - - - - - - - - - - 1 -7.8% table 4.14 examples of ubaud settings for commonly used oscillator frequencies (continued) baud rate fosc=8.00mhz fosc=11.0592mhz fosc=14.7456mhz u2x=0 u2x=1 u2x=0 u2x=1 u2x=0 u2x=1 ubaud error ubaud error ubaud error ubaud error ubaud error ubaud error 2400 207 0.2% - - - - - - - - - - 4800 103 0.2% 207 0.2% 143 0.0% - - 191 0.0% - - 9600 51 0.2% 103 0.2% 71 0.0% 143 0.0% 95 0.0% 191 0.0% 14.4k 34 -0.8% 68 0.6% 47 0.0% 95 0.0% 63 0.0% 127 0.0% 19.2k 25 0.2% 51 0.2% 35 0.0% 71 0.0% 47 0.0% 95 0.0% 28.8k 16 2.1% 34 -0.8% 23 0.0% 47 0.0% 31 0.0% 63 0.0% 38.4k 12 0.2% 25 0.2% 17 0.0% 35 0.0% 23 0.0% 47 0.0% 57.6k 8 -3.5% 16 2.1% 11 0.0% 23 0.0% 15 0.0% 31 0.0% 76.8k 6 -7.0% 12 0.2% 8 0.0% 17 0.0% 11 0.0% 23 0.0% 115.2k 3 8.5% 8 -3.5% 5 0.0% 11 0.0% 7 0.0% 15 0.0% 230.4k 1 8.5% 3 8.5% 2 0.0% 5 0.0% 3 0.0% 7 0.0% 250k 1 0.0% 3 0.0% 2 -7.8% 5 -7.8% 3 -7.8% 6 5.3% 0.5m - - 1 0.0% - - 2 -7.8% 1 -7.8% 3 -7.8% 1m - - - - - - - - - - 1 -7.8%
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 112 4.7 i2c 4.7.1 overview the i2c is one of industrial standard serial communication protocols, and which uses 2 bus lines serial data line (sda) and serial clock line (scl) to exchange data. because both sda and scl lines are open-drain output, each line needs pull-up resistor. the features are as shown below. - compatible with i2c bus standard - multi-master operation - up to 400 khz data transfer speed - 7 bit address - both master and slave operation - bus busy detection 4.7.2 block diagram 4.7.3 i2c bit transfer the data on the sda line must be stable during high period of the clock, scl. the high or low state of the data line can only change when the clock signal on the scl line is low. the exceptions are start(s), repeated start(sr) and stop(p) condition where data line changes when clock line is high. figure 4.27 i2c block diagram sda f/f 8-bit shift register (shftr) slave address register (svadr) noise canceller (debounce) data out register (i2cdr) scl high period register (i2csclhr) scl low period register (i2cscllr) sda hold time register (i2cdahr) sda out controller scl out controller scl noise canceller (debounce) i n t e r n a l b u s l i n e sdain sdaout sclin sclout 1 0 1 0 debounce enable debounce enable
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 113 4.7.4 start / repeated start / stop one master can issue a start (s) condition to notice other devices connected to the scl, sda lines that it will use the bus. a stop (p) condition is generated by the master to release the bus lines so that other devices can use it. a high to low transition on the sda line while scl is high defines a start (s) condition. a low to high transition on the sda line while scl is high defines a stop (p) condition. start and stop conditions are always generated by the master. the bus is considered to be busy after start condition. the bus is considered to be free again after stop condition, ie, the bus is busy between start and stop condition. if a repeated start condition (sr) is generated instead of stop condition, the bus stays busy. so, the start and repeated start conditions are functionally identical. 4.7.5 data transfer every byte put on the sda line must be 8-bits long. the number of bytes that can be transmitted per transfer is unlimited. each byte has to be followed by an acknowledge bit. data is transferred with the most significant bit (msb) first. if a slave can?t receive or transmit another complete byte of data until it has performed some other function, it can hold the clock line scl low to force the master into a wait state. data transfer then continues when the slave is ready for another byte of data and releases clock line scl. figure 4.29 start and stop condition scl sda start condition s p stop condition figure 4.28 bit transfer on the i2c-bus scl sda data line stable: data valid exept s, sr, p change of data allowed
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 114 4.7.6 acknowledge the acknowledge related clock pulse is generated by the master. the transmitter releases the sda line (high) during the acknowledge clock pulse. the receiver must pull down the sda line during the acknowledge clock pulse so that it remains stable low during the high period of this clock pulse. when a slave is addressed by a master (address packet), and if it is unable to receive or transmit because it?s performing some real time function, the data line must be left high by the slave. and also, when a slave addressed by a master is unable to receive more data bits, the slave receiver must release the sda line (data packet). the master can then generate either a stop condition to abort the transfer, or a repeated start condition to start a new transfer. if a master receiver is involved in a transfer, it mu st signal the end of data to the slave transmitter by not generating an acknowledge on the last byte that was clocked out of the slave. the slave transmitter must release the data line to allow the master to generate a stop or repeated start condition. 4.7.7 synchronization / arbitration clock synchronization is performed using the wired-and connection of i2c interfaces to the scl line. this means that a high to low transition on the scl line will cause the devices concerned to start counting off their low period and it will hold th e scl line in that state until the clock high state is reached. however the low to high transition of this clock may not change the state of the scl line if another clock is still within its low period. in this way, a synchronized scl clock is generated with its low period determined by the device with the longest clock low period, and its high period determined by the one with the shortest clock high period. a master may start a transfer only if the bus is free. two or more masters may generate a start condition. arbitration takes place on the sda line, while the scl line is at the high level, in such a way that the master which transmits a high level, while another master is transmitting a low level figure 4.31 acknowledge on the i2c-bus 1 2 8 data output by transmitter 9 ack nack clock pulse for ack data output by receiver scl from master figure 4.30 data transfer on the i2c-bus start or repeated start condition s or sr stop or repeated start condition sr or p msb a cknowledgement si g nal form slave a cknowledgement si g nal form slave byte complete, interrupt within device clock line held low while interrupts are served. 1 9 1 9 ack ack sda scl sr p
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 115 will switch off its data output state because the level on the bus doesn?t correspond to its own level. arbitration continues for many bits until a winning ma ster gets the ownership of i2c bus. its first stage is comparison of the address bits. 4.7.8 operation the i2c is byte-oriented and interrupt based. interrupts are issued after all bus events except for a transmission of a start condition. because the i2c is interrupt based, the application software is free to carry on other operations during a i2c byte transfer. note that when a i2c interrupt is generated, iif flag in i2cmr register is set, it is cleared by writing an arbitrary value to i2csr. when i2c interrupt occurs, the scl line is hold low until writing any value to i2csr. when the iif flag is set, the i2csr contains a value indicating the current state of the i2c bus. according to the value in i2csr, software can decide what to do next. i2c can operate in 4 modes by configuring master/slave, transmitter/receiver. the operating mode is configured by a winning master. a more detailed explanation follows below. figure 4.33 arbitration procedure of two masters device1 dataout scl on bus device2 dataout sda on bus s arbitration process not adaped device 1 loses arbitration device1 outputs high figure 4.32 clock synchronization during arbitration procedure high counter reset fast device sclout low device sclout scl wait high counting start high counting
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 116 4.7.8.1 master transmitter to operate i2c in master transmitter, follow the recommended steps below. 1. enable i2c by setting iicen bit in i2cmr. this provides main clock to the peripheral. 2. load sla+w into the i2cdr where sla is address of slave device and w is transfer direction from the viewpoint of the master. for master transmitter, w is ?0?. note that i2cdr is used for both address and data. 3. configure baud rate by writing desired value to both i2cscllr and i2csclhr for the low and high period of scl line. 4. configure the i2csdahr to decide when sda changes value from falling edge of scl. if sda should change in the middle of scl low period, load half the value of i2cscllr to the i2csdahr. 5. set the start bit in i2cmr. this transmits a start condition. and also configure how to handle interrupt and ack signal. when the start bit is set, 8-bit data in i2cdr is transmitted out according to the baud-rate. 6. this is ack signal processing stage for address packet transmitted by master. when 7-bit address and 1-bit transfer direction is transmitted to target slave device, the master can know whether the slave acknowledged or not in the 9 th high period of scl. if the master gains bus mastership, i2c generates gcall interrupt regardless of the reception of ack from the slave device. when i2c loses bus mastership during arbitration process, the mlost bit in i2csr is set, and i2c waits in idle state or can be operate as an addressed slave. to operate as a slave when the mlsot bit in i2csr is set, the acken bit in i2cmr must be set and the received 7-bit address must equal to the sla bits in i2csar. in this case i2c operates as a slave transmitter or a slave receiver (go to appro priate section). in this stage, i2c holds the scl low. this is because to decide whether i2c continues serial transfer or stops communication. the following steps continue assuming that i2c does not lose mastership during first data transfer. i2c (master) can choose one of the following cases regardless of the reception of ack signal from slave. 1) master receives ack signal from slave, so continues data transfer because slave can receive more data from master. in this case, load data to transmit to i2cdr. 2) master stops data transfer even if it receives ack signal from slave. in this case, set the stop bit in i2cmr. 3) master transmits repeated start condition with not checking ack signal. in this case, load sla+r/w into the i2cdr and set start bit in i2cmr. after doing one of the actions above, write arbitrary value to i2csr to release scl line. in case of 1), move to step 7. in case of 2), move to step 9 to handle stop interrupt. in case of 3), move to step 6 after transmitting the data in i2cdr and if transfer direction bit is ?1? go to master receiver section. 7. 1-byte of data is being transmitted. duri ng data transfer, bus arbitration continues. 8. this is ack signal processing stage for data packet transmitted by master. i2c holds the scl low. when i2c loses bus mastership while transmitting data arbitrating other masters, the mlost bit in i2csr is set. if then, i2c wait s in idle state. when the data in i2cdr is transmitted completely, i2c generates tend interrupt. i2c can choose one of the following cases regardless of the reception of ack signal from slave. 1) master receives ack signal from slave, so continues data transfer because slave can receive more data from master. in this case, load data to transmit to i2cdr. 2) master stops data transfer even if it receives ack signal from slave. in this case, set the stop bit in i2cmr. 3) master transmits repeated start condition with not checking ack signal. in this case, load sla+r/w into the i2cdr and set the start bit in i2cmr.
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 117 after doing one of the actions above, write arbitrary value to i2csr to release scl line. in case of 1), move to step 7. in case of 2), move to step 9 to handle stop interrupt. in case of 3), move to step 6 after transmitting the data in i2cdr, and if transfer direction bit is ?1? go to master receiver section. 9. this is the final step for master transmitt er function of i2c, handling stop interrupt. the stop bit indicates that data transfer between master and slave is over. to clear i2csr, write arbitrary value to i2csr. after this, i2c enters idle state. the next figure depicts above process for master transmitter operation of i2c. figure 4.34 formats and states in the master transmitter mode from master to slave / master command or data write from slave to master 0xxx value of status register ack interrupt , scl line is held low interrupt after stop command p arbitration lost as master and addressed as slave lost& other master continues slave receiver (0x1d) or transmitter (0x1f) master receiver sla+w ack data rs stop lost lost& stop lost s or sr sla+r y n 0x0e 0x87 0x86 0x0e ack stop y n 0x0f 0x1d lost? y 0x47 0x1f 0x46 cont? y n stop 0x0f lost p 0x22 p 0x22 0x22 p
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 118 4.7.8.2 master receiver to operate i2c in master receiver, follow the recommended steps below. 1. enable i2c by setting iicen bit in i2cmr. this provides main clock to the peripheral. 2. load sla+r into the i2cdr where sla is address of slave device and r is transfer direction from the viewpoint of the master. for master rece iver, r is ?1?. note that i2cdr is used for both address and data. 3. configure baud rate by writing desired value to both i2cscllr and i2csclhr for the low and high period of scl line. 4. configure the i2csdahr to decide when sda changes value from falling edge of scl. if sda should change in the middle of scl low period, load half the value of i2cscllr to the i2csdahr. 5. set the start bit in i2cmr. this transmit s a start condition. and also configure how to handle interrupt and ack signal. when the start bit is set, 8-bit data in i2cdr is transmitted out according to the baud-rate. 6. this is ack signal processing stage for address packet transmitted by master. when 7-bit address and 1-bit transfer direction is transmitted to target slave device, the master can know whether the slave acknowledged or not in the 9 th high period of scl. if the master gains bus mastership, i2c generates gcall interrupt regardless of the reception of ack from the slave device. when i2c loses bus mastership during arbitration process, the mlost bit in i2csr is set, and i2c waits in idle state or can be operate as an addressed slave. to operate as a slave when the mlsot bit in i2csr is set, the acken bit in i2cmr must be set and the received 7-bit address must equal to the sla bits in i2csar. in this case i2c operates as a slave transmitter or a slave receiver (go to appro priate section). in this stage, i2c holds the scl low. this is because to decide whether i2c continues serial transfer or stops communication. the following steps continue assuming that i2c does not lose mastership during first data transfer. i2c (master) can choose one of the following cases according to the reception of ack signal from slave. 1) master receives ack signal from slave, so continues data transfer because slave can prepare and transmit more data to master. configure acken bit in i2cmr to decide whether i2c acknowledges the next data to be received or not. 2) master stops data transfer because it receives no ack signal from slave. in this case, set the stop bit in i2cmr. 3) master transmits repeated start condition due to no ack signal from slave. in this case, load sla+r/w into the i2cdr and set start bit in i2cmr. after doing one of the actions above, write arbitrary value to i2csr to release scl line. in case of 1), move to step 7. in case of 2), move to step 9 to handle stop interrupt. in case of 3), move to step 6 after transmitting the data in i2cdr and if transfer direction bit is ?0? go to master transmitter section. 7. 1-byte of data is being received. 8. this is ack signal processing stage for data packet transmitted by slave. i2c holds the scl low. when 1-byte of data is received completely, i2c generates tend interrupt. i2c can choose one of the following cases according to the rxack flag in i2csr. 1) master continues receiving data from slave. to do this, set acken bit in i2cmr to acknowledge the next data to be received. 2) master wants to terminate data transfer when it receives next data by not generating ack signal. this can be done by clearing acken bit in i2cmr. 3) because no ack signal is detected, master te rminates data transfer. in this case, set the stop bit in i2cmr. 4) no ack signal is detected, and master transmits repeated start condition. in this case,
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 119 load sla+r/w into the i2cdr and set the start bit in i2cmr. after doing one of the actions above, write arbi trary value to i2csr to release scl line. in case of 1) and 2), move to step 7. in case of 3), move to step 9 to handle stop interrupt. in case of 4), move to step 6 after transmitting the data in i2cdr, and if transfer direction bit is ?0? go to master transmitter section. 9. this is the final step for master receiver function of i2c, handling stop interrupt. the stop bit indicates that data transfer between master and slave is over. to clear i2csr, write arbitrary value to i2csr. after this, i2c enters idle state. the processes described above for master receiver operation of i2c can be depicted as the following figure. 4.7.8.3 slave transmitter to operate i2c in slave transmitter, follow the recommended steps below. figure 4.35 formats and states in the master receiver mode from master to slave / master command or data write from slave to master 0xxx value of status register ack interrupt , scl line is held low interrupt after stop command p ack arbitration lost as master and addressed as slave lost& other master continues slave receiver (0x1d) or transmitter (0x1f) master transmitter sla+r ack data rs lost lost& stop lost s or sr sla+w y n 0x0c 0x85 0x84 0x0c ack stop y n 0x0d 0x1d 0x45 0x1f 0x44 lost p 0x20 p 0x20 sr 0x44
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 120 1. if the main operating clock (sclk) of the system is slower than that of scl, load value 0x00 into i2csdahr to make sda change within one system clock period from the falling edge of scl. note that the hold time of sda is calculated by sdah x period of sclk where sdah is multiple of number of sclk coming from i2csdahr. when the hold time of sda is longer than the period of sclk, i2c (slave) cannot transmit serial data properly. 2. enable i2c by setting iicen bit and inten bit in i2cmr. this provides main clock to the peripheral. 3. when a start condition is detected, i2c receives one byte of data and compares it with sla bits in i2csar. if the gcallen bit in i2csar is enabled, i2c compares the received data with value 0x00, the general call address. note: general call interrupt can occur as though the received data does not match the general call address. when general call interrupt happens, i2cdr must be checked to match 0x00. 4. if the received address does not equal to sla bi ts in i2csar, i2c enters idle state ie, waits for another start condition. else if the address equals to sla bits and the acken bit is enabled, i2c generates ssel interrupt and the sc l line is held low. note that even if the address equals to sla bits, when the acken bit is disabled, i2c enters idle state. when ssel interrupt occurs, load transmit data to i2cdr and write arbitrary value to i2csr to release scl line. 5. 1-byte of data is being transmitted. 6. in this step, i2c generates tend interrupt and holds the scl line low regardless of the reception of ack signal from master. slave can select one of the following cases. 1) no ack signal is detected and i2c waits stop or repeated start condition. 2) ack signal from master is detected. load data to transmit into i2cdr. after doing one of the actions above, write arbitrary value to i2csr to release scl line. in case of 1) move to step 7 to terminate communication. in case of 2) move to step 5. in either case, a repeated start condition can be detected. for that case, move step 4. 7. this is the final step for slave transmitter function of i2c, handling stop interrupt. the stop bit indicates that data transfer between master and slave is over. to clear i2csr, write arbitrary value to i2csr. after this, i2c enters idle state. the next figure shows flow chart for handling slave transmitter function of i2c.
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 121 4.7.8.4 slave receiver to operate i2c in slave receiver, follow the recommended steps below. 1. if the main operating clock (sclk) of the system is slower than that of scl, load value 0x00 into i2csdahr to make sda change within one sy stem clock period from the falling edge of scl. note that the hold time of sda is calculated by sdah x period of sclk where sdah is multiple of number of sclk coming from i2csdahr. when the hold time of sda is longer than the period of sclk, i2c (slave) cannot transmit serial data properly. 2. enable i2c by setting iicen bit and inten bit in i2cmr. this provides main clock to the peripheral. 3. when a start condition is detected, i2c receives one byte of data and compares it with sla bits in i2csar. if the gcallen bit in i2csar is enabled, i2c compares the received data with value 0x00, the general call address. 4. if the received address does not equal to sla bits in i2csar, i2c enters idle state ie, waits for another start condition. else if the address equals to sla bits and the acken bit is enabled, i2c generates ssel interrupt and the scl line is held low. note that even if the figure 4.36 formats and states in the slave transmitter mode sla+r ack data lost& s or sr y 0x47 ack stop y n 0x46 p 0x22 idle idle y gcall 0x1f 0x97 0x17 from master to slave / master command or data write from slave to master 0xxx value of status register ack interrupt , scl line is held low interrupt after stop command p arbitration lost as master and addressed as slave lost& general call address gcall
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 122 address equals to sla bits, when the acken bit is disabled, i2c enters idle state. when ssel interrupt occurs and i2c is ready to receive data, write arbitrary value to i2csr to release scl line. 5. 1-byte of data is being received. 6. in this step, i2c generates tend interrupt and holds the scl line low regardless of the reception of ack signal from master. slave can select one of the following cases. 1) no ack signal is detected (acken=0) and i2c waits stop or repeated start condition. 2) ack signal is detected (acken=1) and i2c can continue to receive data from master. after doing one of the actions above, write arbitrary value to i2csr to release scl line. in case of 1) move to step 7 to terminate communicat ion. in case of 2) move to step 5. in either case, a repeated start condition can be detected. for that case, move step 4. 7. this is the final step for slave receiver function of i2c, handling stop interrupt. the stop bit indicates that data transfer between master and slave is over. to clear i2csr, write arbitrary value to i2csr. after this, i2c enters idle state. the process can be depicted as following figure when i2c operates in slave receiver mode. sla+w ack data lost& s or sr y n 0x45 ack stop y n 0x44 p 0x20 idle idle y gcall 0x1d 0x95 0x15 from master to slave / master command or data write from slave to master 0xxx value of status register ack interrupt , scl line is held low interrupt after stop command p arbitration lost as master and addressed as slave lost& general call address gcall
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 123 4.7.9 register map table 4.15 i2c register map name address dir default description i2cmr dah r/w 00h i2c mode control register i2csr dbh r 00h i2c status register i2cscllr dch r/w 3fh scl low period register i2csclhr ddh r/w 3fh scl high period register i2csdahr deh r/w 01h sda hold time register i2cdr dfh r/w ffh i2c data register i2csar d7h r/w 00h i2c slave address register 4.7.10 i2c register description i2c registers are composed of i2c mode control register (i2cmr), i2c status register (i2csr), scl low period register (i2cscllr), scl high period register (i2csclhr), sda hold time register (i2csdahr), i2c data register (i2cdr ), and i2c slave address register (i2csar). 4.7.11 register description for i2c i2cmr (i2c mode control register) : dah 7 6 5 4 3 2 1 0 iif iicen reset inten acken imasterl stop start r/w r/w r/w r/w r/w r/w r/w r/w initial value : 00h iif this is interrupt flag bit. 0 no interrupt is generated or interrupt is cleared 1 a n interrupt is generated iicen enable i2c function block (by providing clock) 0 i2c is inactive 1 i2c is active reset initialize internal registers of i2c. 0 no operation 1 initialize i2c, auto cleared inten enable interrupt generation of i2c. 0 disable interrupt, operates in polling mode 1 enable interrupt acken controls ack signal generation at ninth scl period. note) ack signal is output (sda=0) for the following 3 cases. when received address packet equals to sla bits in i2csar when received address packet equals to value 0x00 with gcall enabled when i2c operates as a receiver (master or slave) 0 no ack signal is generated (sda=1) 1 a ck signal is generated (sda=0) master this bit shows whether i2c is in master or slave mode. figure 4.37 formats and states in the slave receiver mode
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 124 0 i2c is in slave mode. 1 i2c is in master mode. stop when i2c is master, generates stop condition. 0 no operation 1 stop condition is to be generated start when i2c is master, generates start condition. 0 no operation 1 start or repeated start condition is to be generated i2csr (i2c status register) : dbh 7 6 5 4 3 2 1 0 gcall tend stop ssel mlost busy tmode rxack r r r r r r r r initial value : 00h gcall this bit has different meaning depending on whether i2c is master or slave. note 1) when i2c is a master, this bit represents whether it received aack (address ack) from slave. when i2c is a slave, this bit is used to indicate general call. 0 no aack is received (master mode) 1 a ack is received (master mode) 0 received address is not general call address (slave mode) 1 general call address is detected (slave mode) tend this bit is set when 1-byte of data is transferred completely. note 1) 0 1 byte of data is not completely transferred 1 1 byte of data is completely transferred stop this bit is set when stop condition is detected. note 1) 0 no stop condition is detected 1 stop condition is detected ssel this bit is set when i2c is addressed by other master. note 1) 0 i2c is not selected as slave 1 i2c is addressed by other master and acts as a slave mlost this bit represents the result of bus arbitration in master mode. note 1) 0 i2c maintains bus mastership 1 i2c has lost bus mastership during arbitration process busy this bit reflects bus status. 0 i2c bus is idle, so any master can issue a start condition 1 i2c bus is busy tmode this bit is used to indicate whether i2c is transmitter or receiver. 0 i2c is a receiver 1 i2c is a transmitter rxack this bit shows the state of ack signal. 0 no ack is received 1 a ck is generated at ninth scl period note 1) these bits can be source of interrupt. when an i2c interrupt occurs except for stop interrupt, the scl line is hold low. to release scl, write arbitrary value to i2csr. when i2csr is written, the tend, stop, ssel, lost, rxack bits are cleared.
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 125 i2cscllr (scl low period register) : dch 7 6 5 4 3 2 1 0 scll7 scll6 scll5 scll4 scll3 scll2 scll1 scll0 r/w r/w r/w r/w r/w r/w r/w r/w initial value : 3fh scll[7:0] this register defines the low period of scl when i2c operates in master mode. the base clock is sclk, the system clock, and the period is calculated by the formula : t sclk (scll + 1) where t sclk is the period of sclk. i2csclhr (scl high period register) : ddh 7 6 5 4 3 2 1 0 sclh7 sclh6 sclh5 sclh4 sclh3 sclh2 sclh1 sclh0 r/w r/w r/w r/w r/w r/w r/w r/w initial value : 3fh sclh[7:0] this register defines the high period of scl when i2c operates in master mode. the base clock is sclk, the system clock, and the period is calculated by the formula : t sclk (sclh + 3) where t sclk is the period of sclk. so, the operating frequency of i2c in master mode (fi2c) is calculated by the following equation. fi2c 1 tsclk scll sclh 4 i2csdahr (sda hold time register) : deh 7 6 5 4 3 2 1 0 sdah7 sdah6 sdah5 sdah4 sdah3 sdah2 sdah1 sdah0 r/w r/w r/w r/w r/w r/w r/w r/w initial value : 01h sdah[7:0] this register is used to control sda output timing from the falling edge of scl. note that sda is changed after t sclk sdah. in master mode, load half the value of scll to this register to make sda change in the middle of scl. in slave mode, configure this register regarding the frequency of scl from master. the sda is changed after t sclk (sdah + 1). so, to insure normal operation in slave mode, the value t sclk (sdah + 1) must be smaller than the period of scl. i2cdr (i2c data register) : dfh 7 6 5 4 3 2 1 0 icd7 icd6 icd5 icd4 icd3 icd2 icd1 icd0 r/w r/w r/w r/w r/w r/w r/w r/w initial value : ffh icd[7:0] when i2c is configured as a transmitter, load this register with data to be transmitted. when i2c is a receiver, the received data is stored into this register. i2csar (i2c slave address register) : d7h 7 6 5 4 3 2 1 0
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 126 sla7 sla6 sla5 sla4 sla3 sla2 sla1 gcallen r/w r/w r/w r/w r/w r/w r/w r/w initial value : 00h sla[7:1] these bits configure the slave address of this i2c module when i2c operates in slave mode. gcallen this bit decides whether i2c allows general call address or not when i2c operates in slave mode. 0 ignore general call address 1 a llow general call address 4.8 12-bit a/d converter 4.8.1 overview the analog-to-digital converter (a/d) allows conversion of an analog input signal to a corresponding 12-bit digital value. the a/d module has tenth analog inputs. the output of the multiplex is the input into the converter, which generates the result via successive approximation. the a/d module has four registers which are the control register adcm (a/d converter mode register), adcm2 (a/d converter mode register 2) and a/d result register adchr (a/d converter result high register) and adclr (a/d converter result low register). it is selected for the corresponding channel to be converted by setting adsel[3:0]. to executing a/d conversion, adst bit sets to ?1?. the register adchr and adclr contains the results of the a/d conversion. when the conversion is completed, the result is loaded into the adchr and adclr, the a/d conversion status bit aflag is set to ?1?, and the a/d interrupt is set. for processing a/d conversion, aflag bit is read as ?0?. if using stby (power down) bit, the adc is disabled. also internal timer, external generating event, comparator, the trigger of timer1pwm and etc. can start adc regardless of interrupt occurrence. adc conversion time = adclk * 60 cycles after stby bit is reset (adc power enable) and it is restarted, during some cycle, adc conversion value may have an inaccurate value.
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 127 4.8.2 block diagram figure 4.38 adc block diagram mux ext vdd vss b/g vref vdc an7 an6 an1 an0 successive approximation circuit adif adcrh[7:0] (8bit) adcrl[7:4] (4bit) aflag resistor ladder circuit adst an0 12bit a/d converter data register ads[3:0] 4 12 adc interrupt pre scaler mux 2 4 8 32 fx cksel[1:0] 2 adst clear comparator [9b h ] [9c h ] adclk 0~1000pf an0 ~ an7 analog input 22uf avdd a nalog power input figure 4.39 a/d analog input pin connecting capacitor figure 4.40 a/d power(avdd) pin connecting capacitor
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 128 4.8.3 adc operation figure 4.42 a/d converter operation flow set adcm2 set adcm aflag = 1? converting start read adcrh/l adc end select adc clock & data align bit. adc enable & select an input channel. start adc conversion. if conversion is completed, aflg is set ?1? and adc interrupt is occurred. after conversion is completed, read adcrh and adcrl. y n figure 4.41 adc operation for align bit align bit set ?0? adco11 adco10 adco9 adco8 adco7 adco6 adco5 adco4 adco3 adco2 adco1 adco0 adcrh7 adcrh6 adcrh5 adcrh4 adcrh3 adcrh2 adcrh1 adcrh0 adcrl7 adcrl6 adcrl5 adcrl4 adcrh[7:0] adcrl[7:4] adcrl[3:0] bits are ?0? align bit set ?1? adco11 adco10 adco9 adco8 adco7 adco6 adco5 adco4 adco3 adco2 adco1 adco0 adcrh3 adcrh2 adcrh1 adcrh0 adcrl7 adcrl6 adcrl5 adcrl4 adcrl3 adcrl2 adcrl1 adcrl0 adcrl[7:0] adcrh[4:0] adcrh[7:4] bits are ?0?
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 129 4.8.4 register map table 4.16 adc register map name address dir default description a dcm 9ah r/w 8fh a /d converter mode register a dcrh 9bh r - a /d converter result high register a dcrl 9ch r - a /d converter result low register a dcm2 9bh r/w 8fh a /d converter mode 2 register 4.8.5 adc register description the adc register consists of a/d converter mode register (adcm), a/d converter result high register (adcrh), a/d converter result low register (adcrl), a/d converter mode 2 register (adcm2). note) when stby bit is set to ?1?, adcm2 can be read. if adc enables, it is possible only to write adcm2.when reading, adcrh is read. 4.8.6 register description for adc adcm (a/d converter mode register) : 9ah 7 6 5 4 3 2 1 0 stby adst refsel aflag adsel3 adsel2 adsel1 adsel0 r/w r/w r/w r/ r/w r/w r/w r/w initial value : 8fh stby control operation of a/d standby (power down) 0 a dc module enable 1 a dc module disable (power down) adst control a/d conversion stop/start. 0 a dc conversion stop 1 a dc conversion start refsel a /d converter reference selection 0 internal reference (vdd) 1 external reference(avref, an0 disable) aflag a /d converter operation state 0 during a/d conversion 1 a /d conversion finished adsel[3:0] a /d converter input selection a dsel3 a dsel2 a dsel1 a dsel0 description 0 0 0 0 channel0(an0) 0 0 0 1 channel1(an1) 0 0 1 0 channel2(an2) 0 0 1 1 channel3(an3) 0 1 0 0 channel4(an4) 0 1 0 1 channel5(an5) 0 1 1 0 channel6(an6) 0 1 1 1 channel7(an7) 1 0 0 0 channel8(n/a) 1 0 0 1 channel9(n/a)
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 130 1 0 1 0 channel10(vdc:1.8v) 1 0 1 1 channel11(bandgap vref:1.17v) 1 1 0 0 channel12(vss) 1 1 0 1 channel13(ext. vdd) 1 1 1 0 channel14(n/a) 1 1 1 1 channel15(n/a) adcrh (a/d converter result high register) : 9bh 7 6 5 4 3 2 1 0 addm11 addm10 addm9 addm8 addm7 addl11 addm6 addl10 addm5 addl9 addm4 addl8 r r r r r r r r initial value : xxh addm[11:4] msb align, a/d converter high result (8-bit) addl[11:8] lsb align, a/d converte r high result (4-bit) adcrl (a/d converter result low register) : 9ch 7 6 5 4 3 2 1 0 addm3 addl7 addm2 addl6 addm1 addl5 addm0 addl4 addl3 addl2 addl1 addl0 r r r r r- r r r initial value : xxh addm[3:0] msb align, a/d converter low result (4-bit) addl[7:0] lsb align, a/d converter low result (8-bit) adcm2 (a/d converter mode register) : 9bh 7 6 5 4 3 2 1 0 extrg tsel2 tsel1 tsel0 amuxen align cksel1 cksel0 r/w r/w r/w r/w r/w r/w r/w r/w initial value : 8fh extrg a /d external trigger 0 external trigger disable 1 external trigger enable tsel[2:0] a /d trigger source selection tsel2 tsel1 tsel0 description 0 0 0 ext. interrupt 0 0 0 1 a nalog comparator low to high 0 1 0 a nalog comparator high to lo w 0 1 1 timer0 interrupt 1 0 0 timer1 interrupt 1 0 1 reserved 1 1 0 reserved 1 1 1 timer4 interrupt amuxen control a/d converter mux output 0 a /d converter mux output disable 1 when stby=1, a/d converter mux output enable
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 131 align a /d converter data align selection. 0 msb align (adcrh[7:0], adcrl[7:4]) 1 lsb align (adcrh[3:0], adcrl[7:0]) cksel[1:0] a /d converter clock selection cksel1 cksel0 a dc clock a dc vdd 0 0 fx/2 test only 0 1 fx/4 3v~5v 1 0 fx/8 2.7v~3v 1 1 fx/32 2.4v~2.7v note) 1. fx : system clock 2. adc clock have to be used 3mhz under. psr0 (adc pin selection register) : 9fh 7 6 5 4 3 2 1 0 ain07_en ain06_en ain05_en ain04_en ain03_en ain02_en ain01_en ain00_en r/w r/w r/w r/w r/w r/w r/w r/w initial value : 00h psr0[7:0] a dc input pin channel selection (disable logic input gate) 0 disable 1 enable
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 132 4.9 analog comparator 4.9.1 overview the analog comparator compares the input values on the positive pin an5 and the negative pin an4. when the voltage on the positive pin an5 is higher than the voltage on the negative pin an4, the analog comparator output, acout, is set. 4.9.2 block diagram 4.9.3 in/out signal description ace : this enables analog comparator. when ace is ?0?, the output of comparator goes low. bgr : band gap reference voltage acbg : this selects (-) input source between bgr and an4. when acbg is ?1?, the (-) input to ac is bgr. an4 : this can be (-) input to the ac, and comes directly from external analog pad. an5 : this can be (+) input to the ac, and comes directly from external analog pad. amuxenb : this selects (+) input source between multiplexed output of adc and an5. amuxenb is the inverted signal of amuxen bit in adcm2 register. when amuxenb is ?0?, the (+) input to ac comes from adc module which is selected by adsel[3:0], the channel selection bits in adcm register. acout : this is the output of comparator. figure 4.43 analog comparator block diagram analog comparator interrupt acbg b/g vf mux an4 adc mux output mux an5 ace acif interrupt select amuxenb (adcm2.3) acism[1:0] acie comparator aco
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 133 4.9.4 register map table 4.17 analog comparator register map name address dir default description a ccsr e9h r/w 00h a nalog comparator control & status register 4.9.5 analog comparator register description analog comparator register has one control register , analog comparator control & status register (accsr). note that amuxenb is the inverted si gnal of amuxen bit which comes from adc?s adcm2 register 4.9.6 register description for analog comparator accsr (analog comparator control & status register) : e9h 7 6 5 4 3 2 1 0 ace acbg aco acif acie - acism1 acism0 r/w r/w r r r/w - r/w r/w initial value : 00h ace enable analog comparator (ac). 0 disable ac (power down) 1 enable ac acbg select (-) input source of ac, band gap reference voltage or an4. 0 (-) input is from an4 1 (-) input is from band gap reference voltage aco this bit represents the value of acout (output of analog comparator). a co bit is sampled by sclk, system clock, twice. when ace is ?0?, this bit is also cleared. 0 comparator output is low 1 comparator output is high acif this bit is set when an analog comparator interrupt is generated according to the acism[1:0] bits. this bit is cleared when analog comparator interrupt is executed or ?0? is written to this bit field. 0 no interrupt generated or cleared 1 interrupt generated acie enable analog comparator interrupt. 0 disable interrupt, polling mode operation 1 enable interrupt acism[1:0] select interrupt mode of analog comparator. a cism1 a cism0 description 0 0 reserved 0 1 interrupt on falling edge of acout 1 0 interrupt on rising edge of acout 1 1 interrupt on both edge of acout psr1 (comparator pin selection register) : a0h 7 6 5 4 3 2 1 0 aco_en
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 134 r/w initial value : 00h psr1[0] a nalog comparator output enable (disable logic input gate) 0 disable 1 enable 4.10 buzzer driver 4.10.1 overview the buzzer consists of 8 bit counter and buzdr (buzzer data register), buzcr (buzzer control register). the square wave (61.035hz~125 khz, @8mhz) gets out of p12/buz pin. buzdr (buzzer data register) controls the buzzer frequency (look at the following expression). in the buzcr (buzzer control register), buck[1:0] selects source clock divided from prescaler. buzdr[7:0] buzzer frequency (khz) buzcr[2:1]=00 buzcr[2:1]=01 buzcr[2:1]=10 buzcr[2:1]=11 0000_0000 125khz 62.5khz 31.25khz 15.625khz 0000_0001 62.5khz 31.25k hz 15.625khz 7.812khz ? ? ? ? ? 1111_1101 492.126hz 246.063hz 123.031hz 61.515hz 1111_1110 490.196hz 245.098hz 122.549hz 61.274hz 1111_1111 488.281hz 244.141hz 122.07hz 61.035hz table 11-12 buzzer frequency at 8 mhz 1) (buzdr ratio prescaler 2 frequency oscillator (hz)f buz ? ? ? ?
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 135 4.10.2 block diagram 4.10.3 register map name address dir default description buzdr 8fh r/w ffh buzzer data register buzcr 96h r/w 00h buzzer control register table 11-13 register map 4.10.4 buzzer driver register description buzzer driver consists of buzzer data register (buzdr), buzzer control register (buzcr). 4.10.5 register description for buzzer driver buzdr (buzzer data register) : 8fh 7 6 5 4 3 2 1 0 buzdr7 buzdr6 buzdr5 buzdr4 buzdr3 buzdr2 buzdr1 buzdr0 r/w r/w r/w r/w r/w r/w r/w r/w initial value : ffh buzdr[7:0] this bits control the buzzer frequency its resolution is 00h ~ ffh buzcr (buzzer control register) : 96h 7 6 5 4 3 2 1 0 - - - - - buck1 buck0 buzen - - - - - r/w r/w r/w initial value : 00h buck[1:0] buzzer driver source clock selection figure 4-38 buzzer driver block diagram pre scaler mux 32 64 128 256 2 f/f buzcr buzcr[2:1] selection input clock buzzer control register [96 h ] 8-bit up-counter counter overflow fx counter buzo pin writing to buzdr reset buzcr[0] buzdr buzzer data register [8f h ]
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 136 buck1 buck0 source clock 0 0 fx/32 0 1 fx/64 1 0 fx/128 1 1 fx/256 buzen buzzer driver operation control 0 buzzer driver disable 1 buzzer driver enable note) fx: main system clock oscillation frequency
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 137 5. power down operation 5.1 overview the Z51F0410 mcu features three power-down modes to minimize the power consumption of the device. in power down mode, power consumption is reduced considerably. the device provides three kinds of power saving functions, idle, stop1 and stop2 mode. in three modes, program is stopped. 5.2 peripheral operation in idle/stop mode table 5.1 peripheral operation during power down mode. peripheral idle mode stop1 mode stop2 mode cpu all cpu operation are disable all cpu operation are disable all cpu operation are disable ram retain retain retain basic interval timer operates continuously operates continuously stop watch dog timer operates continuously operates continuously stop watch timer operates continuously stop (only operate in sub clock mode) stop (only operate in sub clock mode) timerp0~1 operates continuously halted (only when the event counter mode is enable, timer operates normally) halted (only when the event counter mode is enable, timer operates normally) adc operates continuously stop stop buz operates continuously stop stop spi/sci operates continuously only operate with external clock only operate with external clock i2c operates continuously stop stop internal osc (8mhz) oscillation stop stop main osc (1~8mhz) oscillation stop stop sub osc (32.768khz) oscillation oscillation oscillation internal rcosc (128khz) oscillation oscillation stop i/o port retain retain retain control register retain retain retain address data bus retain retain retain release method by reset, all interrupts by reset, timer interrupt (ec0), sio (external clock), external interrupt, uart by ack pci, i2c (slave mode), wt (sub clock),wdt, bit by reset, timer interrupt (ec0), sio (external clock), external interrupt, uart by ack pci, i2c (slave mode), wt (sub clock) 5.3 idle mode the power control register is set to ?01h? to enter th e idle mode. in this mode, the internal oscillation circuits remain active. oscillation continues and peripherals are operated normally but cpu stops. it is released by reset or interrupt. to be released by interrupt, interrupt should be enabled before idle mode. if using reset, because the device becomes initialized state, the registers have reset value.
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 138 figure 5.1 idle mode release timing by external interrupt external interrupt v dd 16ms, 32ms, 64 normal operation release cpu clock stand-by mode normal operation
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 139 5.4 stop mode the power control register is set to ?03h? to enter the stop mode. in the stop mode, the main oscillator, system clock and peripheral clock is stopped, but watch timer continue to operate. with the clock frozen, all functions are stopped, but the on-chip ram and control registers are held. the source for exit from stop mode is hardware reset and interrupts. the reset re-defines all the control registers. when exit from stop mode, enough oscillation stabilization time is required to normal operation. figure 5.2 shows the timing diagram. when released from stop mode, the basic interval timer is activated on wake-up. therefore, before stop instruction, user must be set its relevant prescale divide ratio to have long enough time. this guara ntees that oscillator has started and stabilized. figure 5.2 stop mode release timing by external interrupt osc cpu clock external interrupt normal operation bit counter stop operation normal operation release stop instruction execute clear & start by software setting before executed stop instruction, bit must be set properly by software to get stabilization. n n+1 n+2 n+3 ff 0 1 0 1 fe
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 140 5.5 release operation of stop1, 2 mode after stop1, 2 mode is released, the operation begins according to content of related interrupt register just before stop1, 2 mode start (figure 5.3). interrupt enable flag of all (ea) of ie should be set to `1`. released by only interrupt which each interrupt enable flag = `1`, and jump to the relevant interrupt service routine. 5.5.1 register map table 5.2 pcon register map name address dir default description figure 5.3 stop1, 2 mode release flow set sccr.7 set pcon[1:0] set iex.b stop1, 2 mode iex.b==1 ? interrupt request stop1, 2 mode release y interrupt service routine nest instruction n corresponding interrupt enable bit(ie, ie1, ie2, ie3)
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 141 pcon 87h r/w 00h power control register 5.5.2 power down operation register description the power down operation register consists of the power control register (pcon). 5.5.3 register description for power down operation pcon (power control register) : 87h 7 6 5 4 3 2 1 0 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 r/w r/w r/w r/w r/w r/w r/w r/w initial value : 00h idle mode 01h idle mode enable stop1, 2 mode 03h stop1, 2 mode enable note) 1. to enter idle mode, pcon must be set to ?01h?. 2. to stop1,2 mode, pcon must be set to ?03h?. (in stop1,2 mode, pcon register is cleared automatically by interrupt or reset) 3. when pcon is set to ?03h?, if sccr[7] is set to ?1?, it enters the stop1 mode. if sccr[7] is cleared to ?0?, it enters the stop2 mode 4. the different thing in stop 1,2 is only cl ock operation of internal 128khz-osc during stop mode operating.
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 142 6. reset 6.1 overview the Z51F0410 mcu features reset by external resetb pin. the following is the hardware setting value. table 6.1 reset state on chip hardware initial value program counter (pc) 0000h accumulator 00h stack pointer (sp) 07h peripheral clock on control register peripheral registers refer brown-out detector enable 6.2 reset source the Z51F0410 mcu features five types of reset generation procedures. the following is the reset sources. - external resetb - power on reset (por) - wdt overflow reset (in the case of wdten = `1`) - bod reset (in the case of boden = `1 `) - ocd reset 6.3 block diagram 6.4 reset noise canceller the figure 6.2 is the noise canceller diagram for noise cancel of reset. it has the noise cancel value of about 7us (@v dd =5v) to the low input of system reset. figure 6.1 reset block diagram wdt rst wdt rsten ext reset disable by fuse reset noise canceller bod_out bod enable reset noise canceller wdt rst wdt rst s q r internal reset ifbit (bit overflow)
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 143 6.5 power on reset when rising device power, the por (power on reset) have a function to reset the device. if using por, it executes the device reset function inst ead of the reset ic or the reset circuits. and external reset pin is able to be used as normal i/o pin. figure 6.4 internal reset release timing on power-up vdd npor (internal signal) internal resetb oscillation bit starts bit overflows slow vdd rise time, max 0.02v/ms v por =1.4v (typ) figure 6.3 fast vdd rising time vdd npor (internal signal) internal resetb oscillation bit starts bit overflows fast vdd rise time figure 6.2 reset noise canceller time diagram t > t rnc t > t rnc t > t rnc t < t rnc t < t rnc a a
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 144 figure 6.5 configuration timing when power-on v dd 16ms, 32ms, 64 internal npor pad resetb (r20) bit (for config) bod_resetb bit (for reset) int-osc 128khz/32 int-osc (128khz) reset_sysb config read 250us (4khz) x 30h = about 12ms 250us x 40h = about 16ms 00 01 02 03 04 05 06 00 01 02 03 00 01 02 .. .. .. .. .. 2f 30 31 3f 40 00 01 02 03 .. ext_reset have not an effect on counter value for config read counting for config read start after por is released ?h? int-osc 128khz / 32 = 4khz (250us) xx xx . xx xx .. .. x x config data config 26 bytes 16ms, 32ms, 64ms selectable
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 145 table 6.2 boot process description process description remarks -no operation -1st por level detection -internal osc (128khz) on -about 1.4v ~ 1.5v - (int-osc128khz/32) 30h delay section (=12ms) -vdd input voltage must rise over than flash operating voltage for config read -slew rate 0.025v/ms - config read point -about 1.5v ~ 1.6v -config value is determined by writing option | - rising section to reset release level -16ms point after por or ext_reset release - reset release section (bit overflow) i) after16ms, after external reset release (external reset) ii) 16ms point after por (por only) - bit is used for peripheral stability -normal operation 6.6 external resetb input the external resetb is the input to a schmitt trigger. a reset in accomplished by holding the reset pin low for at least 7us over, within the operating voltage range and oscillation stable, it is applied, and the internal state is initialized. after reset state be comes ?1?, it needs the stabilization time with 16ms figure 6.6 boot process wave form reset release config read por :vdd input :internal osc |
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 146 and after the stable state, the internal reset becomes ?1?. the reset process step needs 5 oscillator clocks. and the program execution starts at the vector address stored at address 0000h. note) as shown figure 13-8, the stable generating time is not included in the start-up time. 6.7 brown out detector processor the Z51F0410 mcu features an on-chip brown-out detection circuit for monitoring the vdd level during operation by comparing it to a fixed trigger level. the trigger level for the bod can be selected by bodls[1:0] bit to be 1.6v, 2.5v, 3.6v or 4.3v. in the stop mode, this will contribute significantly to the total current consumption. so to minimize the current consumption, the boden bit is set to off by software. figure 6.8 oscillator generating waveform example osc start timing prescaler count start vdd figure 6.7 timing diagram after reset osc address bus core bus main program stabilization time tst = 16ms ? resetb release internal resetb release 1 2 3 4 5 ? 00 01 02 ? ? ? ? ? ? ? 02 reset process step
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 147 vdd internal resetb vdd internal resetb v bod max v bod min 16ms t < 16ms 16ms v bod max v bod min figure 6.9 block diagram of bod bodls[1:0] reset_bodb brown out detector (bod) d q cp r d q cp r debounce clk external vdd boden bodrf (bod reset flag) cpu write sclk (system clk) npor mux stop_mode 0 1
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 148 6.7.1 register map table 6.3 bod register map name address dir default description bodr 0x86 r/w 81h bod control register 6.7.2 reset operation register description reset control register consists of the bod control register (bodr). 6.7.3 register description for reset operation bodr (bod control register) : 81h 7 6 5 4 3 2 1 0 porf extrf wdtrf ocdrf bodrf bodls[1] bodls[0] boden r/w r/w r/w r/w r/w r/w r/w r/w initial value : 81h porf power-on reset flag bit. the bit is reset by writing ?0? to this bit. 0 no detection figure 6.11 configuration timing when bod reset vdd internal npor pad resetb (r20) bit (for config) bod_resetb bit (for reset) int-osc 128khz/32 int-osc (128khz) reset_sysb config read 250us x 30h = about 12ms 250us x 40h = about 16ms f1 00 01 02 00 01 02 .. .. .. .. .. 2f 30 f1 3f 40 00 01 02 03 .. ?h? int-osc 128khz / 32 = 4khz (250us) ?h? ?h? main osc off figure 6.10 internal reset at the power fail situation
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 149 1 detection extrf external reset flag bit. the bit is reset by writing ?0? to this bit or by power on reset. 0 no detection 1 detection wdtrf watch dog reset flag bit. the bit is reset by writing ?0? to this bit or by power on reset. 0 no detection 1 detection ocdrf on-chip debug reset flag bit. the bit is reset by writing ?0? to this bit or by power on reset. 0 no detection 1 detection bodrf brown-out reset flag bit. the bit is reset by writing ?0? to this bit or by power on reset. 0 no detection 1 detection bodls[1:0] bod level voltage bodls1 bodls0 description 0 0 1.6v 0 1 2.5v 1 0 3.6v 1 1 4.3v boden bod operation 0 bod disable 1 bod enable
Z51F0410 product specification ps029501-0212 p r e l i m i n a r y 150 7. on-chip debug system 7.1 overview 7.1.1 description on-chip debug system (ocd) of the Z51F0410 mcu can be used for programming the non-volatile memories and on-chip debugging. detailed descriptions for programming via the ocd interface can be found in the following chapter. figure 7.1 shows a block diagram of the ocd interface and the on-chip debug system. 7.1.2 feature ? two-wire external interface: 1-wire serial clock input, 1-wire bi-directional serial data bus ? debugger access to: ? all internal peripheral units ? internal data ram ? program counter ? flash and data eeprom memories ? extensive on-chip debug support for break conditions, including ? break instruction ? single step break ? program memory break points on single address ? programming of flash, eeprom, fuses, and lock bits through the two-wire interface ? on-chip debugging supported by dr.choice ? ? operating frequency supports the maximum frequency of the target mcu figure 7.1 block diagram of on-chip debug system bdc format converter usb cpu code memory - sram - flash - eeprom data memory dbg register peripheral user i/o a ddress bus internal data bus dsda dscl t arget mcu internal circuit dbg control
Z51F0410 product specification ps029501-0212 p r e l i m i n a r y 151 7.2 two-pin external interface 7.2.1 basic transmission packet ? 10-bit packet transmission using two-pin interface. ? 1-packet consists of 8-bit data, 1-bit parity and 1-bit acknowledge. ? parity is even of ?1? for 8-bit data in transmitter. ? receiver generates acknowledge bit as ?0? when transmission for 8-bit data and its parity has no error. ? when transmitter has no acknowledge (acknowledge bit is ?1? at tenth clock), error process is executed in transmitter. ? when acknowledge error is generated, host pc makes stop condition and transmits command which has error again. ? background debugger command is composed of a bundle of packet. ? star condition and stop condition notify the st art and the stop of background debugger command respectively. figure 7.2 10-bit transmission packet
Z51F0410 product specification ps029501-0212 p r e l i m i n a r y 152 7.2.2 packet transmission timing 7.2.2.1 data transfer 7.2.2.2 bit transfer 7.2.2.3 start and stop condition figure 7.5 start and stop condition st sp start condition stop condition dsda dscl dsda dscl figure 7.4 bit transfer on the serial bus data line stable: data valid except start and stop change of data allowed dsd a dscl figure 7.3 data transfer on the twin bus st sp start stop dsda dscl lsb acknowledgement signal from receive r a c k a ck 1 10 110 acknowledgement signal from receive r lsb
Z51F0410 product specification ps029501-0212 p r e l i m i n a r y 153 7.2.2.4 acknowledge bit 7.2.3 connection of transmission two-pin interface connection uses open-drain (wire-and bidirectional i/o). figure 7.7 clock synchronization during wait procedure start wait start high host pc dscl out target device dscl out dscl wait high maximum 5 t sclk internal operation a cknowledge bit transmission minimum 1 t sclk for next byte transmission a cknowledge bit transmission minimum 500ns figure 7.6 acknowledge on the serial bus 1 9 2 10 data output by transmitte r data output by receive r dscl from maste r clock pulse for acknowledgement no acknowledge acknowledge
Z51F0410 product specification ps029501-0212 p r e l i m i n a r y 154 figure 7.8 connection of transmission dsc l ou t dsd a ou t dsd a in dscl(debugger serial clock line) dsda(debugger serial data line) dsd a ou t dsd a in host machine(master) t arget device(slave) vdd vdd current source for dscl to fast 0 to 1 transition in high speed mode pull -up resistors rp rp vdd dsc l in dscl ou t dscl in
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 155 8. memory programming 8.1 overview 8.1.1 description the Z51F0410 mcu incorporates flash and data eeprom memory to which a program can be written, erased, and overwritten while mounted on the board. also, data eeprom can be programmed or erased in user program. serial isp modes and byte-parallel rom writer mode are supported. 8.1.2 features ? flash size : 4kbytes ? single power supply program and erase ? command interface for fast program and erase operation ? up to 10,000 program/erase cycles at typical voltage and temperature for flash memory ? up to 100,000 program/erase cycles at typical voltage and temperature for data eeprom memory ? security feature 8.2 flash and eeprom control and status register registers to control flash and data eeprom are mode register (femr), control register (fecr), status register (fesr), time control register (fetcr), address low register (fearl), address middle register (fearm), address high register (fearh) and data register (fedr). they are mapped to sfr area and can be accessed only in programming mode. 8.2.1 register map table 8-1 flash and eeprom register map name address dir default description femr eah r/w 00h flash and eeprom mode register fecr ebh r/w 03h flash and eeprom control register fesr ech r/w 80h flash and eeprom status register fetcr edh r/w 00h flash and eeprom time control register fearl f2h r/w 00h flash and eeprom address low register fearm f3h r/w 00h flash and eeprom address middle register fearh f4h r/w 00h flash and eeprom address high register fedr f5h r/w 00h flash and eeprom data register
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 156 8.2.2 register description for flash and eeprom femr (flash and eeprom mode register) : eah 7 6 5 4 3 2 1 0 fsel esel pgm erase pbuff otpe vfy feen r/w r/w r/w r/w r/w r/w r/w r/w initial value : 00h fsel select flash memory. 0 deselect flash memory 1 select flash memory esel select data eeprom 0 deselect data eeprom 1 select data eeprom pgm enable program or program verify mode with vfy 0 disable program or program verify mode 1 enable program or program verify mode erase enable erase or erase verify mode with vfy 0 disable erase or erase verify mode 1 enable erase or erase verify mode pbuff select page buffer 0 deselect page buffer 1 select page buffer otpe select otp area instead of program memory 0 deselect otp area 1 select otp area vfy set program or erase verify mode with pgm or erase program verify: pgm=1, vfy=1 erase verify: erase=1, vfy=1 feen enable program and erase of flash and data eeprom. when inactive, it is possible to read as normal mode 0 disable program and erase 1 enable program and erase fecr (flash and eeprom control register) : ebh 7 6 5 4 3 2 1 0 aef aee exit1 exit0 write read nferst npbrst r/w r/w r/w r/w r/w r/w r/w r/w initial value : 03h aef enable flash bulk erase mode 0 disable bulk erase mode of flash memory 1 enable bulk erase mode of flash memory aee enable data eeprom bulk erase mode 0 disable bulk erase mode of data eeprom 1 enable bulk erase mode of data eeprom exit[1:0] exit from program mode. it is cleared automatically after 1 clock exit1 exit0 description 0 0 don?t exit from program mode 0 1 don?t exit from program mode
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 157 1 0 don?t exit from program mode 1 1 exit from program mode write start to program or erase of flash and data eeprom. it is cleared automatically after 1 clock 0 no operation 1 start to program or erase of flash and data eeprom read start auto-verify of flash or data eeprom. it is cleared automatically after 1 clock 0 no operation 1 start auto-verify of flash or data eeprom nferst reset flash or data eeprom control lo gic. it is cleared automatically after 1 clock 0 no operation 1 reset flash or data eeprom control logic. npbrst reset page buffer with pbuff. it is cleared automatically after 1 clock pbuff npbrst description 0 0 page buffer reset 1 0 write checksum reset write and read bits can be used in program, erase and verify mode with fear registers. read or writes for memory cell or page buffer uses read and write enable signals from memory controller. indirect address mode with fear is only allowed to program, erase and verify fesr (flash and eeprom status register) : ech 7 6 5 4 3 2 1 0 pevbsy vfygood pcrcrd encrypt romint wmode emode vmode r r/w r/w r/w r/w r r r initial value : 80h pevbsy operation status flag. it is cleared automatically when operation starts. operations are program, erase or verification 0 busy (operation processing) 1 complete operation vfygood a uto-verification result flag. 0 a uto-verification fails 1 a uto-verification successes pcrcrd crc calculation data read control 0 fearh, fearm, fearl represents 24bit checksum 1 fearm, fearl represent 16bit crc result encrypt encryption mode control for pgm 0 normal data pgm mode 1 encryption pgm mode romint flash and data eeprom interrupt request flag. auto-cleared when program/erase/verify starts. active in program/erase/verify completion 0 no interrupt request. 1 interrupt request. wmode write mode flag emode erase mode flag vmode verify mode flag fearl (flash and eeprom address low register) : f2h
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 158 7 6 5 4 3 2 1 0 arl7 arl6 arl5 arl4 arl3 arl2 arl1 arl0 r/w r.w r.w r.w r.w r.w r.w r.w initial value : 00h arl[7:0] flash and eeprom address low chksum[7:0] checksum result from auto verify mode (pcrcrd==0) crc[7:0] crc result from auto verify mode (pcrcrd==1) fearm (flash and eeprom address middle register) : f3h 7 6 5 4 3 2 1 0 arm7 arm6 arm5 arm4 arm3 arm2 arm1 arm0 r/w r.w r.w r.w r.w r.w r.w r.w initial value : 00h arm[7:0] flash and eeprom address middle chksum[15:8] checksum result from auto verify mode crc[15:8] crc result from auto verify mode (pcrcrd==1) fearh (flash and eeprom address high register) : f4h 7 6 5 4 3 2 1 0 arh7 arh6 arh5 arh4 arh3 arh2 arh1 arh0 r/w r.w r.w r.w r.w r.w r.w r.w initial value : 00h arh[7:0] flash and eeprom address high chksum[23:16] checksum result from auto verify mode fear registers are used for program, erase and auto-verify. in program and erase mode, it is page address and ignored the same least significant bits as the number of bits of page address. in auto- verify mode, address increases automatically by one. fears are write-only register. reading these registers returns 24-bit checksum result fedr (flash and eeprom data control register) : f5h 7 6 5 4 3 2 1 0 fedr7 fedr6 fedr5 fedr4 fedr3 fedr2 fedr1 fedr0 w w w w w w w w initial value : 00h fedr[7:0] flash and eeprom data data register. in no program/erase/verify mode, read/write of fecr read or write data from eeprom or flash to this register or from this register to flash or eeprom. the sequence of writing data to this register is used for eeprom program entry. the mode entrance sequence is to write 0xa5 and 0x5a to it in order. fetcr (flash and eeprom time control register) : edh 7 6 5 4 3 2 1 0 tcr7 tcr6 tcr5 tcr4 tcr3 tcr2 tcr1 tcr0
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 159 r/w r/w r/w r/w r/w r/w r/w r/w initial value : 00h tcr[7:0] flash and eeprom time control program and erase time is controlled by setting fetcr register. program and erase timer uses 10- bit counter. it increases by one at the edge of 128khz clock (f fetcr ). it is cleared when program or erase starts. timer stops when 10-bit counter is same to fetcr. pevbsy is cleared when program, erase or verify start and set when program, erase or verify stop. maximum program/erase time: 1/f fetcr * 1024 = 8ms (1/f fetcr = 7.8us @128khz clock) in the case of 50% of error rate of counter source clock, program or erase time are 4~12ms * program/erase time calculation for page write or erase, tpe = (tcon+1) * 2 * 1/f fetcr for bulk erase, tbe = (tcon+1) * 4 * 1/f fetcr recommended program/erase time (fetcr = ffh) min typ max unit program/erase time 2 4 6 ms bulk erase time 4 8 12 ms
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 160 8.3 memory map 8.3.1 flash memory map program memory uses 4-kbyte of flash memory. it is read by byte and written by byte or page. one page is 32-byte figure 8.2 address configuration of flash memory 15 14 13 12 11 10 9 8 7 6 543210 page address word address program memor y 0x1f 0x00 0x0000 0xffff * page buffer size: 32bytes page 2048 page 2047 page 0 page 1 figure 8.1 flash memory map 4kbytes 0000h ffffh flash f e a r 0fffh p r o g r a m c o u n t e r mu x pgm/ers/vfy
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 161 8.3.2 data eeprom memory map data eeprom memory uses 256-byte of eeprom. it is read by byte and written by byte or page. one page is 16-byte. it is mapped to external data memory of 8051 figure 8.4 address configuration of data eeprom 15 14 13 12 11 10 9 8 76543 21 0 page address word address data memor y 0xf 0x0 0x0000 0xffff *page buffer size: 16bytes page 4096 page 4095 page 0 page 1 figure 8.3 data eeprom memory map data eeprom (256bytes) xdata memor y 0000h 00ffh ffffh d p t r f e a r l mu x pgm/ers/vfy
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 162 8.4 serial in-system program mode serial in-system program uses the interface of debugger which uses two wires. refer to chapter 14 in details about debugger 8.4.1 flash operation configuration (this configuration is just used for follow description) 7 6 5 4 3 2 1 0 - femr[4] & [1] femr[5] & [1] - - femr[2] fecr[6] fecr[7] - erase&vfy pgm&vfy - - otpe aee aef figure 8.5 the sequence of page program and erase of flash memory page buffer rese t page buffer load(0x00h) erase erase latency(500us) page buffer rese t configuration reg. setting cell read pass/fail? no page buffer rese t page buffer load program pgm latency(500us) page buffer rese t configuration reg. setting cell read y es pass/fail? configuration reg. clear master reset in the case of otp otpe flag se t in the case of otp otpe flag se t
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 163 8.4.1.1 flash read step 1. enter ocd(=isp) mode. step 2. set enbdm bit of bcr. step 3. enable debug and request debug mode. step 4. read data from flash. 8.4.1.2 enable program mode step 1. enter ocd(=isp) mode. 1 step 2. set enbdm bit of bcr. step 3. enable debug and request debug mode. step 4. enter program/erase mode sequence. 2 (1) write 0xaa to 0xf555. (2) write 0x55 to 0xfaaa. figure 8.6 the sequence of bu lk erase of flash memory page buffer reset page buffer load configuration reg.<0> se t erase latency(500us) page buffer reset configuration reg.<0> clear reg.<6:5> setting master rese t erase cell read pass/fail?
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 164 (3) write 0xa5 to 0xf555. 1 refer to how to enter isp mode.. 2 command sequence to activate flash write/erase mode. it is composed of sequentially writing data of flash memory. 8.4.1.3 flash write mode step 1. enable program mode. step 2. reset page buffer. femr: 1000_0001 fecr:0000_0010 step 3. select page buffer. femr:1000_1001 step 4. write data to page buffer.(address automatically increases by twin.) step 5. set write mode. femr:1010_0001 step 6. set page address. f earh:fearm:fearl=20?hx_xxxx step 7. set fetcr. step 8. start program. fecr:0000_1011 step 9. insert one nop operation step 10. read fesr until pevbsy is 1. step 11. repeat step2 to step 8 until all pages are written. 8.4.1.4 flash page erase mode step 1. enable program mode. step 2. reset page buffer. femr: 1000_0001 fecr:0000_0010 step 3. select page buffer. femr:1000_1001 step 4. write ?h00 to page buffer. (data value is not important.) step 5. set erase mode. femr:1001_0001 step 6. set page address. f earh:fearm:fearl=20?hx_xxxx step 7. set fetcr. step 8. start erase. fecr:0000_1011 step 9. insert one nop operation step 10. read fesr until pevbsy is 1. step 11. repeat step2 to step 8 until all pages are erased. 8.4.1.5 flash bulk erase mode step 1. enable program mode. step 2. reset page buffer. femr: 1000_0001 fecr:0000_0010 step 3. select page buffer. femr:1000_1001 step 4. write ?h00 to page buffer. (data value is not important.) step 5. set erase mode. femr:1001_0001. (only main cell area is erased. for bulk erase including otp area, select otp area.(set femr to 1000_1101.) step 6. set fetcr step 7. start bulk erase. fecr:1000_1011
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 165 step 9. insert one nop operation step 9. read fesr until pevbsy is 1. 8.4.1.6 flash otp area read mode step 1. enter ocd(=isp) mode. step 2. set enbdm bit of bcr. step 3. enable debug and request debug mode. step 4. select otp area. femr:1000_0101 step 5. read data from flash. 8.4.1.7 flash otp area write mode step 1. enable program mode. step 2. reset page buffer. femr: 1000_0001 fecr:0000_0010 step 3. select page buffer. femr:1000_1001 step 4. write data to page buffer.(address automatically increases by twin.) step 5. set write mode and select otp area. femr:1010_0101 step 6. set page address. f earh:fearm:fearl=20?hx_xxxx step 7. set fetcr. step 8. start program. fecr:0000_1011 step 9. insert one nop operation step 10. read fesr until pevbsy is 1. 8.4.1.8 flash otp area erase mode step 1. enable program mode. step 2. reset page buffer. femr: 1000_0001 fecr:0000_0010 step 3. select page buffer. femr:1000_1001 step 4. write ?h00 to page buffer. (data value is not important.) step 5. set erase mode and select otp area. femr:1001_0101 step 6. set page address. f earh:fearm:fearl=20?hx_xxxx step 7. set fetcr. step 8. start erase. fecr:0000_1011 step 9. insert one nop operation step 10. read fesr until pevbsy is 1. 8.4.1.9 flash program verify mode step 1. enable program mode. step 2. set program verify mode. femr:1010_0011 step 3. read data from flash.
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 166 8.4.1.10 otp program verify mode step 1. enable program mode. step 2. set program verify mode. femr:1010_0111 step 3. read data from flash. 8.4.1.11 flash erase verify mode step 1. enable program mode. step 2. set erase verify mode. femr:1001_0011 step 3. read data from flash. 8.4.1.12 flash page buffer read step 1. enable program mode. step 2. select page buffer. femr:1000_1001 step 3. read data from flash. 8.4.2 data eeprom operation program and erase operation of data eeprom are executed by direct and indirect address mode. direct address mode uses external data area of 8051. indirect address mode uses address register of sfr area.. 8.4.2.1 data eeprom read step 1. enter ocd(=isp) mode. step 2. set enbdm bit of bcr. step 3. enable debug and request debug mode. step 4. read data from data eeprom. 8.4.2.2 enable program mode step 1. enter ocd(=isp) mode. 1 step 2. set enbdm bit of bcr. step 3. enable debug and request debug mode. step 4. enter program/erase mode sequence. 2 (1) write 0xa5 to fedr. (2) write 0x5a to fedr. 1 refer to how to enter isp mode.. 2 command sequence to activate data eeprom write/erase mode. it is composed of sequentially writing to data register(fedr)
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 167 8.4.2.3 eeprom write mode step 1. enable program mode. step 2. reset page buffer. femr: 0100_0001 fecr:0000_0010 step 3. select page buffer. femr:0100_1001 step 4. write data to page buffer.(address automatically increases by twin.) step 5. set write mode. femr:0110_0001 step 6. set page address. f earh:fearm:fearl=20?hx_xxxx step 7. set fetcr. step 8. start program. fecr:0000_1011 step 9. insert one nop operation step 10. read fesr until pevbsy is 1. step 11. repeat step2 to step 8 until all pages are written. 8.4.2.4 eeprom page erase mode step 1. enable program mode. step 2. reset page buffer. femr: 0100_0001 fecr:0000_0010 step 3. select page buffer. femr:0100_1001 step 4. write ?h00 to page buffer. (data value is not important.) step 5. set erase mode. femr:0101_0001 step 6. set page address. f earh:fearm:fearl=20?hx_xxxx step 7. set fetcr. step 8. start erase. fecr:0000_1011 step 9. insert one nop operation step 10. read fesr until pevbsy is 1. step 11. repeat step2 to step 8 until all pages are erased. 8.4.2.5 eeprom bulk erase mode step 1. enable program mode. step 2. reset page buffer. femr: 0100_0001 fecr:0000_0010 step 3. select page buffer. femr:0100_1001 step 4. write ?h00 to page buffer. (data value is not important.) step 5. set erase mode. femr:0101_0001. step 6. set fetcr step 7. start bulk erase. fecr:0100_1011 step 8. insert one nop operation step 9. read fesr until pevbsy is 1. 8.4.2.6 data eeprom program verify mode step 1. enable program mode. step 2. set program verify mode. femr:0110_0011
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 168 step 3. read data from flash. 8.4.2.7 data eeprom erase verify mode step 1. enable program mode. step 2. set erase verify mode. femr:0101_0011 step 3. read data from flash. 8.4.2.8 data eeprom page buffer read step 1. enable program mode. step 2. select page buffer. femr:0100_1001 step 3. read data from flash. 8.4.3 summary of flash and data eeprom program/erase mode table 8-2 flash and data eeprom operation mode operation mode description f l a s h flash read read cell by byte. flash write write cell by bytes or page. flash page erase erase cell by page. flash bulk erase erase the whole cells. flash program verify read cell in verify mode after programming. flash erase verify read cell in verify mode after erase. flash page buffer load load data to page buffer. e e p r o m data eeprom read read cell by byte. data eeprom write write cell by bytes or page. data eeprom page erase erase cell by page. data eeprom bulk erase erase the whole cells. data eeprom program verify read cell in verify mode after programming. data eeprom erase verify read cell in verify mode after erase. data eeprom page buffer load load data to page buffer.
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 169 8.5 parallel mode 8.5.1 overview parallel program mode transfers address and data by byte. 3-byte address can be entered by one from the lease significant byte of address. if only lsb is changed, only one byte can be transferred. and if the second byte is changed, the first and second byte can be transferred. upper 4-bit of the most significant byte selects memory to be accessed. table 8-1 shows memory type. address auto- increment is supported when read or write data without address table 8-3 the selection of memory type by addrh[7:4] addrh[7:4] memory type 0 0 0 0 program memory 0 0 0 1 external memory 0 0 1 0 sfr figure 8.7 pin diagram for parallel programming pdata[7:0] nwr nale resetb nrd
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 170 8.5.2 parallel mode instruction format table 8-4 parallel mode instruction format instruction signal instruction sequence n-byte data read with 3-byte address nale l l l h h h h nwr l h l h l h h h h h h h h h nrd h h h h h h l h l h l h l h pdata addrl addrm addrh data0 data1 --- datan n-byte data write with 3-byte address nale l l l h h h h nwr l h l h l h l h l h l h l h nrd h h h h h h h h h h h h h h pdata addrl addrm addrh data0 data1 --- datan n-byte data read with 2-byte address nale l l h h h h h nwr l h l h h h h h h h h h h h nrd h h h h l h l h l h l h l h pdata addrl addrm data0 data1 data2 --- datan n-byte data write with 2-byte address nale l l h h h h h nwr l h l h l h l h l h l h l h nrd h h h h h h h h h h h h h h pdata addrl addrm data0 data1 data2 --- datan n-byte data read with 1-byte address nale l h h h h h h nwr l h h h l h l h l h l h l h nrd h h l h h h h h h h h h h h pdata addrl data0 data1 data2 data3 --- datan n-byte data write with 1-byte address nale l h h h h h h nwr l h l h l h l h l h l h l h nrd h h h h h h h h h h h h h h pdata addrl data0 data1 data2 data3 --- datan
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 171 8.5.3 parallel mode timing diagram table 8-5 control pin description pin p01 p02 p03 p04 p05 function pdata[0] pdata[1] nale nwr nrd 8.6 mode entrance method of isp and byte-parallel mode 8.6.1 mode entrance method for isp target mode r03 r05 r03 figure 8.9 parallel byte write timing of program memory nw r nrd pdat a write 0x00 @0x0f000 a m(f0h) a l(00h) write 0x01 @0x0a000h a m(a0h) a l(00h) a l(01h) write 0x02 @0x0a001 write write write write write write write write read address auto- increment a h(00h) write al am a hd a t a al am data al data out data 1 - byte write with 3 - byte address 1 - byte write with 2 - byte address 2- byte write with 1 - byte address write 0x03 @0x0a002 di(00h) di(01h) di(02h) di(03h) nale t aws t awh figure 8.8 parallel byte read timing of program memory nale nw r nrd pdat a read @0f000h a m(f0h) a l(00h) do read @0a000h a m(a0h) a l(00h) a l(01h) do read @0a001h write write write read write write read write read address auto- increment a h(00h) do read al am a h data out al am data out al data out data out do 1 - byte read with 3 1- byte read with 2 -byte address 2- byte read with 1-byte address read @0a002h t aws t awh t ars t arh -byte address
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 172 ocd(isp) ?hc ?hc ?hc 8.6.2 mode entrance of byte-parallel target mode r0[7:6],r0[3],r0[1] r0[7 :6],r0[3],r0[1] r0[7:6],r0[3],r0[1] byte-parallel mode 4?h5 4?ha 4?h5 figure 8.11 byte-parallel mode (10pin package only) power on reset pad_resetb (r02) r05 r0[7],[6],[3],[1] reset_sysb ? h5 ? ha ? h5 release from worst 1.7v low period required during more 10us if external reset is used sample r0[7:6],r0[3],r0[1]at the falling edge of r05 figure 8.10 isp mode power on rese t pad_resetb (r02) r05 r03 reset_sysb release from worst 1.7v low period required during more 10us if external reset is used
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 173 8.7 security the Z51F0410 mcu provides one lock bit which can be left unprogrammed (?0?) or can be programmed (?1?) to obtain the additional features listed in table 8-6. the lock bit can only be erased to ?0? with the bulk erase command table 8-6 security policy using lock-bits lock mode user mode isp/pmode/btmode flash data eeprom otp flash data eeprom otp loc ke loc kf r w p e b e r w p e b e rw p e b e rw p e b e rw p e b e r w p e b e 0 0 x x x x o o o o x x x x o o o o o o o o o o o o 0 1 x x x x o o o o x x x x x x x o o o o o o x x o 1 0 x x x x o o o o x x x x o x x x o o 1 1 x x x x o o o o x x x x x x x x x x o o x x ? lockf: lock bit of flash memory ? locke: lock bit of data eeprom ? r: read ? w: write ? pe: page erase ? be: bulk erase ? o: operation is possible. ? x: operation is impossible. ? : when locke is programmed, each operation can be done after data eeprom is erased with the bulk erase command.
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 174 9. configure option 9.1 configure option control register fuse_conf (pseudo-configure data) : 0x00:fdh 7 6 5 4 3 2 1 0 bitp[1:0] sxinen xinena rstdis encrypt locke lockf r r r r r r r r initial value : 00h bitp[1;0] bit period control (reset release time control) 00 16ms 01 32ms 10 64ms sxinen external sub oscillator enable bit 0 sub osc disable (default) 1 sub osc enable xinena external main oscillator enable bit 0 main osc disable (default) 1 main osc enable rstdis external resetb disable bit 0 external reset enable 1 external reset disable encrypt super lock enable bit (encryption mode) 0 super lock disable 1 super lock enable (rom data encrypted) locke data memory lock bit 0 lock disable 1 lock enable lockf code memory lock bit 0 lock disable 1 lock enable useed0 (user lock private key) : 0x06:d4h 7 6 5 4 3 2 1 0 useed0[7:0] - - - - - - - - initial value : 00h useed0[7:0] user seed key for code encryption useed0 is only available when encrypt is 1 useed1 (user lock private key) : 0x07:d3h 7 6 5 4 3 2 1 0 useed1[7:0] - - - - - - - - initial value : 00h useed1[7:0] user seed key for code encryption
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 175 useed1 is only available when encrypt is 1 9.2 serial id the Z51F0410 mcu supports 16 bytes of user serial id for device identification. these id are mapped to sfr area. user can write sid to 0x0a~0x19 of otp area and read sid of sfr by indirect adressing mode. sid is mappet to d6h and sida to d5h. sidx (serial id x) : d5h 7 6 5 4 3 2 1 0 sidx[7:0] - - - - - - - - initial value : 00h sidx[7:0] user serial id x x is from 0 to 15. table 9-1 summary of sid otp address initial value sid0 0x0a 00h sid1 0x0b 00h sid2 0x0c 00h sid3 0x0d 00h sid4 0x0e 00h sid5 0x0f 00h sid6 0x10 00h sid7 0x11 00h sid8 0x12 00h sid9 0x13 00h sid10 0x14 00h sid11 0x15 00h sid12 0x16 00h sid13 0x17 00h sid14 0x18 00h sid15 0x19 00h
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 176 10. appendix 10.1 instruction table instructions are either 1, 2 or 3 bytes long as listed in the ?bytes? column below. each instruction takes either 1, 2 or 4 machine cycles to execute as listed in the following table. 1 machine cycle comprises 2 system clock cycles. arithmetic mnemonic description bytes cycles hex code add a,rn add register to a 1 1 28-2f add a,dir add direct byte to a 2 1 25 add a,@ri add indirect memory to a 1 1 26-27 add a,#data add immediate to a 2 1 24 addc a,rn add register to a with carry 1 1 38-3f addc a,dir add direct byte to a with carry 2 1 35 addc a,@ri add indirect memory to a with carry 1 1 36-37 addc a,#data add immediate to a with carry 2 1 34 subb a,rn subtract register from a with borrow 1 1 98-9f subb a,dir subtract direct byte from a with borrow 2 1 95 subb a,@ri subtract indirect memory from a with borrow 1 1 96-97 subb a,#data subtract immediate from a with borrow 2 1 94 inc a increment a 1 1 04 inc rn increment register 1 1 08-0f inc dir increment direct byte 2 1 05 inc @ri increment indirect memory 1 1 06-07 dec a decrement a 1 1 14 dec rn decrement register 1 1 18-1f dec dir decrement direct byte 2 1 15 dec @ri decrement indirect memory 1 1 16-17 inc dptr increment data pointer 1 2 a3 mul ab multiply a by b 1 4 a4 div ab divide a by b 1 4 84 da a decimal adjust a 1 1 d4 logical mnemonic description bytes cycles hex code anl a,rn and register to a 1 1 58-5f anl a,dir and direct byte to a 2 1 55 anl a,@ri and indirect memory to a 1 1 56-57 anl a,#data and immediate to a 2 1 54 anl dir,a and a to direct byte 2 1 52 anl dir,#data and immediate to direct byte 3 2 53 orl a,rn or register to a 1 1 48-4f orl a,dir or direct byte to a 2 1 45 orl a,@ri or indirect memory to a 1 1 46-47 orl a,#data or immediate to a 2 1 44 orl dir,a or a to direct byte 2 1 42 orl dir,#data or immediate to direct byte 3 2 43 xrl a,rn exclusive-or register to a 1 1 68-6f xrl a,dir exclusive-or direct byte to a 2 1 65 xrl a, @ri exclusive-or indirect memory to a 1 1 66-67 xrl a,#data exclusive-or immediate to a 2 1 64 xrl dir,a exclusive-or a to direct byte 2 1 62 xrl dir,#data exclusive-or immediate to direct byte 3 2 63 clr a clear a 1 1 e4 cpl a complement a 1 1 f4 swap a swap nibbles of a 1 1 c4 rl a rotate a left 1 1 23 rlc a rotate a left through carry 1 1 33 rr a rotate a right 1 1 03
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 177 rrc a rotate a right through carry 1 1 13 data transfer mnemonic description bytes cycles hex code mov a,rn move register to a 1 1 e8-ef mov a,dir move direct byte to a 2 1 e5 mov a,@ri move indirect memory to a 1 1 e6-e7 mov a,#data move immediate to a 2 1 f8-ff mov rn,a move a to register 1 1 a8-af mov rn,dir move direct byte to register 2 2 78-7f mov rn,#data move immediate to register 2 1 f5 mov dir,a move a to direct byte 2 1 88-8f mov dir,rn move register to direct byte 2 2 85 mov dir,dir move direct byte to direct byte 3 2 86-87 mov dir,@ri move indirect memo ry to direct byte 2 2 75 mov dir,#data move immediate to direct byte 3 2 f6-f7 mov @ri,a move a to indirect memory 1 1 a6-a7 mov @ri,dir move direct byte to indirect memory 2 2 76-77 mov @ri,#data move immediate to indirect memory 2 1 90 mov dptr,#data move immediate to data pointer 3 2 93 movc a,@a+dptr move code byte relative dptr to a 1 2 83 movc a,@a+pc move code byte relative pc to a 1 2 e2-e3 movx a,@ri move external data(a8) to a 1 2 f2-f3 movx a,@dptr move external data(a16) to a 1 2 f0 movx @ri,a move a to external data(a8) 1 2 c0 movx @dptr,a move a to external data(a16) 1 2 23 push dir push direct byte onto stack 2 2 c0 pop dir pop direct byte from stack 2 2 d0 xch a,rn exchange a and register 1 1 c8-cf xch a,dir exchange a and direct byte 2 1 c5 xch a,@ri exchange a and indirect memory 1 1 c6-c7 xchd a,@ri exchange a and indirect memory nibble 1 1 d6-d7 boolean mnemonic description bytes cycles hex code clr c clear carry 1 1 c3 clr bit clear direct bit 2 1 c2 setb c set carry 1 1 d3 setb bit set direct bit 2 1 d2 cpl c complement carry 1 1 b3 cpl bit complement direct bit 2 1 b2 anl c,bit and direct bit to carry 2 2 82 anl c,/bit and direct bit inverse to carry 2 2 b0 orl c,bit or direct bit to carry 2 2 72 orl c,/bit or direct bit inverse to carry 2 2 a0 mov c,bit move direct bit to carry 2 1 a2 mov bit,c move carry to direct bit 2 2 92 branching mnemonic description bytes cycles hex code acall addr 11 absolute jump to subroutine 2 2 11 f1 lcall addr 16 long jump to subroutine 3 2 12 ret return from subroutine 1 2 22 reti return from interrupt 1 2 32 ajmp addr 11 absolute jump unconditional 2 2 01 e1 ljmp addr 16 long jump unconditional 3 2 02 sjmp rel short jump (relative address) 2 2 80 jc rel jump on carry = 1 2 2 40 jnc rel jump on carry = 0 2 2 50 jb bit,rel jump on direct bit = 1 3 2 20 jnb bit,rel jump on direct bit = 0 3 2 30 jbc bit,rel jump on direct bit = 1 and clear 3 2 10 jmp @a+dptr jump indirect relative dptr 1 2 73 jz rel jump on accumulator = 0 2 2 60
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 178 jnz rel jump on accumulator 0 2 2 70 cjne a,dir,rel compare a,di rect jne relative 3 2 b5 cjne a,#d,rel compare a,immediate jne relative 3 2 b4 cjne rn,#d,rel compare register, immediate jne relative 3 2 b8-bf cjne @ri,#d,rel compare indirect, immediate jne relative 3 2 b6-b7 djnz rn,rel decrement regist er, jnz relative 3 2 d8-df djnz dir,rel decrement direct byte, jnz relative 3 2 d5 miscellaneous mnemonic description bytes cycles hex code nop no operation 1 1 00 additional instructions (selected through eo[7:4]) mnemonic description bytes cycles hex code movc @(dptr++),a m8051w/m8051ew-specific instruction supporting software download into program memory 1 2 a5 trap software break command 1 1 a5 in the above table, an entry such as e8-ef indicates a continuous block of hex opcodes used for 8 different registers, the register numbers of which are defined by the lowest three bits of the corresponding code. non-continuous blocks of codes, shown as 11 f1 (for example), are used for absolute jumps and calls, with the top 3 bits of the code being used to store the top three bits of the destination address. the cjne instructions use the abbreviation #d for immediate data; other instructions use #data.
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 179 10.2 instructions on how to use the input port. ? error occur status ? using compare jump instructions with input port, it could cause error due to the timing conflict inside the mcu. ? compare jump instructions which cause potential error used with input port condition: jb bit, rel ; jump on direct bit=1 jnb bit, rel ; jump on direct bit=0 jbc bit, rel ; jump on direct bit=1 and clear cjne a, dir, rel ; compare a, direct jne relative djnz dir, rel ; decrement direct byte, jnz relative ? it is only related with input port. internal par ameters, sfrs and output bit ports don?t cause an y error by using compare jump instructions. ? if input signal is fixed, there is no error in using compare jump instructions. ? error status example ? preventative measures (2 cases) while(1){ if (p00==1) { p10=1; } else { p10=0; } p11^=1; } zzz: jnb 080.0, xxx ; it can cause an error setb 088.0 sjmp yyy xxx: clr 088.0 yyy: mov c,088.1 cpl c mov 088.1,c sjmp zzz unsigned char re t_bit_err(void) { return !p00 ; } mov r7, #000 jb 080.0, xxx ; it can cause an error mov r7, #001 xxx: ret
Z51F0410 product specification ps029502-0212 p r e l i m i n a r y 180 ? do not use input bit port for bit operation but for byte operation. using byte operation instead of bit operation will not cause any error in using compare jump instructions for input port. if you use input bit port for compare jump instru ction, you have to copy the input port as internal register or carry bit and then use compare jump instruction. while(1){ if ((p0&0x01)==0x01) { p10=1; } else { p10=0; } p11^=1; } zzz: mov a, 080 ; read as byte jnb 0e0.0, xxx ; compare setb 088.0 sjmp yyy xxx: clr 088.0 yyy: mov c,088.1 cpl c mov 088.1,c sjmp zzz bit tt; while(1){ tt=p00; if (tt==0){ p10=1;} else { p10=0;} p11^=1; } zzz: mov c,080.0 ; input port to c mov 020.0, c ; c to internal register jb 020.0, xxx ; compare with internal register setb 088.0 sjmp yyy xxx: clr 088.0 yyy: mov c,088.1 cpl c mov 088.1,c sjmp zzz
ps029502-0212 p r e l i m i n a r y customer support Z51F0410 product specification 181 customer support to share comments, get your technical questio ns answered, or report issues you may be experiencing with our products, please visit zilog?s technical support page at ? http://support.zilog.com . to learn more about this product, find additional documentation, or to discover other fac- ets about zilog product offerings, please visit the zilog knowledge base or consider par- ticipating in the zilog forum . this publication is subject to replacement by a later edition. to determine whether a later edition exists, please vis it the zilog website at http://www.zilog.com .


▲Up To Search▲   

 
Price & Availability of Z51F0410

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X